Android dpi冰淇淋三明治问题

Android dpi冰淇淋三明治问题,android,android-resources,dpi,qualifiers,Android,Android Resources,Dpi,Qualifiers,我有两个值文件夹: 价值观 值-sw320dp 我在带有冰淇淋三明治的设备上运行了这个应用程序 尽管该设备有240 dpi的显示器,但它从values-sw320dp文件夹中读取值,而不是从values文件夹中读取值 <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2011 Ximpl All Rights Reserved. This program and the accompanying ma

我有两个值文件夹:

  • 价值观
  • 值-sw320dp
我在带有冰淇淋三明治的设备上运行了这个应用程序

尽管该设备有240 dpi的显示器,但它从values-sw320dp文件夹中读取值,而不是从values文件夹中读取值

 <?xml version="1.0" encoding="utf-8"?>
 <!--
 Copyright (C) 2011 Ximpl
 All Rights Reserved. This program and the accompanying materials
 are owned by Ximpl or its suppliers.  The program is protected by international copyright   
    laws and treaty provisions.  Any violation will be prosecuted under applicable laws.

  NOTICE: The following is Source Code and is subject to all restrictions on such code as contained in the End User License Agreement accompanying 
   this product.


        -->
  <resources>
 <dimen name="selectYourCountrySize">14sp</dimen>
 </resources>

14便士

这个beahviour的原因是什么?

sw限定符用于根据设备上可用的最小宽度定义值(因此,当处于纵向模式时)。这不是基于设备密度

屏幕的基本尺寸,由可用屏幕区域的最短尺寸表示。具体来说,设备的最小宽度是屏幕可用高度和宽度中最短的(您也可以将其视为屏幕的“最小可能宽度”)。您可以使用此限定符来确保,无论屏幕的当前方向如何,您的应用程序的UI至少有可用宽度的dps


如果您想拥有
/res
文件夹,尤其是对于密度高于320dpi的设备,则应使用以下文件夹名称:

  values-xhdpi 
如果您只想将其用于API 15及以上版本(您对此不太清楚),可以使用:

  values-v15
或者甚至可以将其结合起来:

  values-xhdpi-v15

您好,那么我也要重命名sw-320dp吗?如果您想根据显示密度使用不同的值,则需要插入带有dpi限定符的不同文件夹。例如:值ldpi、值mdpi、值hdpi、值xhdpi