Search code examples
androidandroid-resourcesdpiqualifiers

Android dpi ice cream sandwich problems


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?


Solution

  • The sw qualifier is used to define values based on smallest width avaialable on the device (so, when is in portrait mode). It's not based on the device density.

    The fundamental size of a screen, as indicated by the shortest dimension of the available screen area. Specifically, the device's smallestWidth is the shortest of the screen's available height and width (you may also think of it as the "smallest possible width" for the screen). You can use this qualifier to ensure that, regardless of the screen's current orientation, your application has at least dps of width available for its UI.

    Source