Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion with "smallest width 600 dp" selector

In my application I am supporting phone/tablet form factors and to have individual layouts I use selector "layout" (for phones), "layout-sw600dp" (for tablets).

Following are the details:

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 am having a Nexus 4 mobile, following are 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 dp calculation formula the dp value comes as 386, but when I pass 1280 px the dp value comes as 644.

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

As the resolution is width X Height, it will be reversed when the device is rotated.

I thought this is the improvisation made with sw selectors compare to pre-3.2 large, xlarge sectors.

like image 778
Mukesh Bhojwani Avatar asked Apr 19 '13 12:04

Mukesh Bhojwani


1 Answers

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

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

like image 109
SK9 Avatar answered Oct 11 '22 05:10

SK9