Michael
Michael

Reputation: 2128

Android layout folder configuration

I currently have 2 layout folders: layout-sw480dp and layout-sw720dp, both containing main.xml

I see that dev guide states the following:

 - 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
   hdpi, etc).
 - 480dp: a tweener tablet like the Streak (480x800 mdpi).
 - 600dp: a 7” tablet (600x1024 mdpi).
 - 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

I'm developing using my Nexus 7 (emulator is a bit sucky/slow), when I upload my app to my tablet, I can tell it uses layout-sw480dp, but why? Ok it's not a 10" tablet but the Nexus 7 does have 800x1280 res, which I guess is irrelevant? I'm just a little confused as to which swdp to have.

According to GSMArena: http://www.gsmarena.com/asus_google_nexus_7-4850.php

 - 800 x 1280 pixels, 7.0 inches (~216 ppi pixel density)

Upvotes: 3

Views: 1392

Answers (2)

whyoz
whyoz

Reputation: 5246

To take this even further, I was testing on my Nexus 7 and on a 600x1024mdpi emulator and found that the two will be considerably off.

The quick way to fix this would be to create the layout folders:

layout-sw600dp-land-tvdpi

layout-sw600dp-port-tvdpi

This has been tested and verified to work for the Nexus 7 specifically since the tvdpi density is rare.

So the layout folders:

layout-sw600dp-land

layout-sw600dp-port

would then be for devices with a mdpi density. There are way more devices that fall into the second category, so you really shouldn't rely on using the naming convention without tvdpi to support the Nexus 7.

This obviously can apply to the Galaxy Note and other devices that are hdpi and so on.

Upvotes: 0

Anirudh
Anirudh

Reputation: 2524

Its sw600dp which is smallest width 600 dp units not pixels so your code is behaving correctly. The screen is 600 x 961 dp units.

Refer to this post for a detailed explanation - https://plus.google.com/105051985738280261832/posts/6eWwQvFGLV8

Upvotes: 3

Related Questions