How can I name my resource folder for another screen size?
For example I see in google codelab something like this:
layout-h470dp
layout-w960dp
You have a few keywords that you need to know: smallestWidth (sw), Available width (w), Available height (h), Screen size (small, normal, large, xlage) and Density qualifier (ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, nodpi, tvdpi).
When naming the package for drawables you will choose one density qualifier, for layout resources you will choose one of the others. If you choose by screen size, you just need to put the word "layout" and the size you want, like layout-small
.
The minimum layout size for a small screen is approximately 320x426 dp units, for normal approximately 320x470, for large 480x640 and for xlarge 720x960.
But if you want you can specify the density you want. The formula is sw N dp or w N dp or h N dp, for example: if your layout requires a screen width of at least 320 dp you will name the package layout-sw320dp, or you your layout will work only if there is 760dp avaiable you will set layout-w720dp or layout-h720dp, depending on width or height. Have in mind that setting w or h will depend on the avaiable size, and this change with screen rotation and with persistent UI elements.
Now if you're working with drawables you will need to choose one of those when naming the package:
ldpi (~120dpi), mdpi (~160dpi), hdpi (~240dpi), xhdpi (~320dpi), xxhdpi (~480dpi), xxxhdpi (~640dpi).
nodpi = Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
tvdpi = Resources for screens somewhere between mdpi and hdpi; approximately 213dpi.
Examples of package names: drawable-ldpi
, drawable-hdpi
.
Some topics of the docs where you can see more details: Providing Resources, Screen Sizes, Multiscreen Screensizes, and Screen Densities.
Related question: Android Resources by Screen Size.