Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.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/5/fortran/2.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 屏幕高度为640 dp的xxhdpi设备使用xhdpi而不是h640dp xhdpi_Android_Android Resources_Dpi - Fatal编程技术网

Android 屏幕高度为640 dp的xxhdpi设备使用xhdpi而不是h640dp xhdpi

Android 屏幕高度为640 dp的xxhdpi设备使用xhdpi而不是h640dp xhdpi,android,android-resources,dpi,Android,Android Resources,Dpi,我在以下文件夹中有资源: 值xhdpi <?xml version="1.0" encoding="utf-8"?> <resources> <string name="test_str">values-xhdpi</string> <style name="test"> <item name="android:background">#aaaaff</item> &l

我在以下文件夹中有资源:

值xhdpi

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="test_str">values-xhdpi</string>

    <style name="test">
        <item name="android:background">#aaaaff</item>
    </style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="test_str">values-mdpi</string>

    <style name="test">
        <item name="android:background">#ffaaaa</item>
    </style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="test_str">values-h640dp-xhdpi</string>

    <style name="test">
        <item name="android:background">#cacaca</item>
    </style>
</resources>
但是,当我在Nexus5上运行我的应用程序时,它使用了
值xhdpi
中的资源。为什么?


更新#1

这就是我错的地方:

让我们检查一下可用高度,并排除可能影响高度的资源 与设备配置相矛盾:

值xhdpi

值mdpi

数值-h640dp-xhdpi

由于一个矛盾,值-h640dp-xhdpi被删除(请参见其中的解释),而值mdpi和值xhdpi被保留。Nexus5的密度是xxhdpi,但是没有为xxhdpi指定资源。因此,最好的匹配是较小屏幕xhdpi的资源

具体来说,当基于大小限定符选择资源时, 系统将使用为小于屏幕的屏幕设计的资源 如果没有更好匹配的资源,则显示当前屏幕(对于 例如,如果出现以下情况,大屏幕将使用正常大小的屏幕资源: (必要的)。但是,如果唯一可用的资源大于 在当前屏幕上,系统将不使用它们和您的应用程序 如果没有其他资源与设备配置匹配,将崩溃


Nexus 5是:-445 ppi像素密度

三星Galaxy Nexus I9250:-316 ppi像素密度

这就是为什么它使用来自value xhdpi的资源

values-h640dp-xhdpi-三星Galaxy Nexus I9250


我们可以在文档中看到xhdpi-Nexus 5的值

当应用程序提供多个资源目录时 对于此配置的不同值,系统使用 最接近(但不超过设备当前屏幕高度)

Nexus 5屏幕高度为567,但您的高度为640,这就是为什么Android不包括此文件夹。

ppi与dpi不同。-445 ppi<代码>adb外壳wm密度输出<代码>物理密度:480dpi
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="test_str">values-h640dp-xhdpi</string>

    <style name="test">
        <item name="android:background">#cacaca</item>
    </style>
</resources>
<TextView
    style="@style/test"
    android:text="@string/test_str"
    android:textSize="46sp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>