Search code examples
androidandroid-studiodpidimensionscreen-density

Dimen value confusion in Android


I have the requirement like this

For Width: sw0-320: 100dp,

sw321- : 200dp

Where should i put this values?

In values folder: 100dp or 200dp,

In values-w320dp folder: 100dp or 200dp,

Confused here! Studied some doc but didn’t understand the fact here!


Solution

  • Android finds the most specific resource it can for the device it's running on first.

    This means if you place something in values-sw320dp and you are running a device with a smallest width of 320dp or more, it will look here first. If it can't find the resource in that folder, it will look in the base values folder. If you are running a device with a smallest width of 319dp, it will not look in values-sw320dp for a resource.