Question

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?

Was it helpful?

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

OTHER TIPS

if you want to have /res folder especially for devices with higher density than 320dpi then you should use following folder name:

  values-xhdpi 

for the case you want it for only API 15 and above (you were not so clear about that) you could use:

  values-v15

or even a combination of it would be possible:

  values-xhdpi-v15
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top