2014-02-24 43 views
2

我有兩個值的文件夾:DPI的Android Ice Cream Sandwich的問題

  • 價值觀sw320dp

我跑了Ice Cream Sandwich的設備上的應用程序。

儘管設備具有240 dpi顯示屏,但它將從值中讀取值 - sw320dp文件夾,而不是值文件夾。

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

這是什麼原因造成的?

回答

4

sw限定符用於根據設備上可用的最小寬度定義值(因此,處於縱向模式時)。它不基於設備密度。

屏幕的基本尺寸,如可用屏幕區域的最短尺寸所示。具體而言,設備的最小寬度是屏幕可用高度和寬度中最短的一個(也可以將其視爲屏幕的「最小可能寬度」)。您可以使用此限定符來確保,不管屏幕的當前方向如何,您的應用程序的UI的可用寬度至少爲dps。

Source

+0

嗨,那麼,我該怎麼重命名sw-320dp? – user3278732

+0

如果您想根據顯示密度使用不同的值,則需要使用dpi限定符插入不同的文件夾。 例如:values-ldpi,values-mdpi,values-hdpi,values-xhdpi – simoneL

2

,如果你想有一個專門的設備/res文件夾超過320dpi高密度,那麼你應該使用下面的文件夾名稱:

values-xhdpi 

的情況下,你希望它僅用於API 15及以上(你不太清楚)你可以使用:

values-v15 

或甚至它的組合將是可能的:

values-xhdpi-v15