Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中添加更多dimens.xml文件?_Android_Xml_User Interface_Size - Fatal编程技术网

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

如何在android中添加更多dimens.xml文件?,android,xml,user-interface,size,Android,Xml,User Interface,Size,我的UI的xml文件中有一个LinearLayout <LinearLayout android:layout_width="fill_parent" android:layout_height="170dp" android:gravity="center_vertical|center_horizontal"> <ImageView android:layout_width="fill_par

我的
UI
xml
文件中有一个
LinearLayout

<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
中指定了
布局的
高度。我的GUI在不同的
模拟器中是不同的。在Nexus 5 emulator中它很好,但在Nexus S emulator中它不正确。我的
LinearLayout
不在
Nexus S emulator的屏幕上。解决办法是什么

我也试过使用
sp
,但没有用


谢谢。

android系统将根据设备特征从“values”文件夹中选择正确的dimens.xml

一些特点:

  • 屏幕密度
  • 屏幕大小
  • 屏幕方向
  • 例如: 设备A是具有大屏幕的HDPI

    文件夹名称应为:

    大hdpi值

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

    就像一套带有大屏幕和XHDPI的设备


    只需在每个不同的
    值xyz
    文件夹中提供不同的
    dimens.xml
    即可显示我应该创建的许多
    值xyz
    文件夹?它如何识别应该执行什么
    dimen.xml
    ?需要多少。安卓为你做这件事。比如当你为你的图形元素设置多个
    可绘制的xyz
    文件夹时。我还没有理解你之前的评论。默认情况下,当我在
    android studio
    中创建
    project
    时,会创建两个
    dimens.xml
    文件。但只创建了一个
    values文件夹
    。而且我没有任何
    可绘制的xyz
    文件。所以。。。你真的没读过书吗?!