Confusion with selector "smallest width 600 dp"

In my application, I support the phone / tablet form factor, and for individual layouts I use the selector “layout” (for phones), “layout-sw600dp” (for tablets).

The following is the data:

http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html

Typical numbers for screen width dp are: 320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc). 480: a tweener tablet like the Streak (480x800 mdpi). 600: a 7" tablet (600x1024). 720: a 10" tablet (720x1280, 800x1280, etc). 

I have a Nexus 4 mobile phone following its attirbutes

 Size: 4.7 inches Resolution: 768 x 1280 pixels DPI: 318 dp: 386 Here is the dp calculation dp = (px * 160)/dpi dp = (768 * 160)/318 

When I use 768 px in the dp calculation formula, the dp value appears as 386, but when I pass 1280 px, the dp value appears as 644.

With the following understanding, I thought that for the Nexus 4 landscape it would read the layout from sw600dp, but that is not the case.

Since the resolution is width X Height, turning the device will cancel it.

I thought this improvisation done with sw selectors compares to pre-3.2 large, large sectors.

+7
source share
2 answers

As the Android documentation says here in bold (scroll down a bit to the "smallestWidth" section in table 2):

Small width is a fixed screen size characteristic of the device; The smallestWidth device does not change when the screen changes orientation .

+18
source

Sw is always the shortest of two screen sizes, regardless of device orientation. Where the "smallest" name "smallestWidth" comes from. The advantage over the "big", etc. In the style of gingerbread. Selectors are just what you get more control detail, and more predictable what screen sizes you get, because it does not rely on how the manufacturer classifies their screen size.

If you want to select a layout based on the width or height of the screen in the current orientation, use a directory called layout-w600dp or layout-h600dp .

+8
source

All Articles