如何在 android 中添加更多 dimens.xml 个文件?

How to add more dimens.xml files in android?

我的 xml 文件中有一个 LinearLayout 用于 UI

<LinearLayout
     android:layout_width="fill_parent"
     android:layout_height="170dp"
     android:gravity="center_vertical|center_horizontal">
          <ImageView
                android:layout_width="fill_parent"
                android:layout_height="70dp"
                android:gravity="center_horizontal|center_vertical"
                android:src="@drawable/menu_profile_icon" />
</LinearLayout>

我在dp中指定了Layoutheight。我的 GUI 因 emulators 不同而不同。它在 Nexus 5 emulator 中很好,但在 Nexus S emulator 中是不正确的。我的 LinearLayoutNexus S emulator 中超出了屏幕。它的解决方案是什么?

我也试过用sp,但是没用,

谢谢。

android系统会根据设备特性从"values"文件夹中选择正确的dimens.xml。

一些特征:

  1. 屏幕密度
  2. 屏幕尺寸
  3. 屏幕方向

示例: 设备 A 是带有大屏幕的 HDPI。

文件夹名称应为:

values-large-hdpi

您必须为每个集合构建具有特定值的维度。

喜欢大屏幕和XHDPI的设备组。

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/topics/resources/available-resources.html