0

I'm trying to figure out how to define different layout for different screen density.

At the moment I have to manage a 7" (Nexus 7), 10" (galaxy tab S) and now a 9.7" (Galaxy tab A) tablets

So I've defined for now two layouts directories :

layout       (for 7")
layout-sw720dp (should be only for 10")

My problem is the 9.7" tablet match the layout-sw720dp directory as my 10" tablet. So from this point I don't know how to define another layout directory based only on my 9.7" tablet.

The density of the 10" is 288ppi and the density of the 9.7" is 132ppi. I guess if the density would be the same I wouldn't have this problem.

Is it possible to create a new directory layout based only on the density ? What is the best practice for this use case and manage at the same time my 10" layout and my 9.7" layout with a different density ?

Alex DG
  • 1,859
  • 2
  • 22
  • 34
  • "I'm trying to figure how to define different layout for different screen density" -- IMHO, that's a code smell. – CommonsWare Nov 03 '15 at 14:53
  • Maybe its useful for you taking a look at this http://stackoverflow.com/questions/29956014/why-should-we-use-xml-layouts – Nanoc Nov 03 '15 at 15:03
  • Of course you can use the folders mdpi,hdpi,xhdpi for the layouts as well. – Nanoc Nov 03 '15 at 15:18

2 Answers2

0

What I've done is instead of using layout-sw720dp I used these two layouts:

layout-hpdi for 10" with hight dpi
layout-mdpi for 9.7 with medium dpi

And it seems to work good.

Edit

Actually I kept layout-sw720dp and then I use also a value-hdpi and value-mdpi resource directories to manage at the same time screen size and density.

Alex DG
  • 1,859
  • 2
  • 22
  • 34
0

you have two options for this either you use

layout-sw600dp
layout-sw720dp
layout-sw800dp

or use the dpi wise folder structure like this

drawable-land-mdpi
drawable-land-hdpi
drawable-land-xhdpi
drawable-land-xxhdpi

Sumit Pathak
  • 529
  • 2
  • 7
  • 24