2

I have two values folders:

  • values
  • values-sw320dp

I ran the application on a device with Ice Cream Sandwich.

Despite the device has a 240 dpi display, it reads values from the values-sw320dp folder, rather then values folder.

 <?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>

Which is the reason of this beahviour?

4

2 回答 2

4

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

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

资源

于 2014-02-24T19:03:01.087 回答
2

如果您想为/res密度高于 320dpi 的设备创建文件夹,则应使用以下文件夹名称:

  values-xhdpi 

对于您只希望 API 15 及更高版本(您对此不太清楚)的情况,您可以使用:

  values-v15

或者甚至是可能的组合:

  values-xhdpi-v15
于 2014-02-24T19:08:36.790 回答