我的安卓应用程序在我的移动设备上正常运行。
但是在平板电脑或其他具有不同分辨率的设备中,元素剂量的大小不会改变。它们显示为小.我认为我的应用程序应该能够适应不同的分辨率,但我不知道我该怎么办?我在下面写一些我的鳕鱼。它们的大小不会改变。
<View
android:id="@+id/view_top"
android:layout_width="250dp"
android:layout_height="60dp"
android:layout_below="@+id/view_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
/>
<Spinner
android:id="@+id/spinner_first"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/view_top"
android:layout_alignRight="@+id/view_top"
android:layout_toLeftOf="@+id/button1"
/>
<EditText
android:id="@+id/edt_number"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/spinner_first"
android:layout_toLeftOf="@+id/spinner_first"
android:ems="10"
android:inputType="phone" >
</EditText>
使用维度资源:
例如:
android:layout_width="250dp"
必须将其更改为:
android:layout_width="@dimen/mycustomwidth"
想知道如何为每个设备分辨率定义自定义宽度吗?
去彻底了解"dimens.xml"文件以及Android官方指南支持多个屏幕的更多信息。
必须创建维度文件在每个文件中,您输入 ECH 设备中使用的值。例如,您在其中创建 Values-xLarge 创建 dimen.xml 文件 。值-HDPI, 值-XHDPI ...