4

I have a Layout that I would like to use only for tablets. I know that if create a folder "layout-v(api level)" that layout will be used only for that specific api. the thing is, for tablets, either you have api 11, 12, or 13. Is there a way I can create a folder that includes all of these instead of creating layout-v11, layout-v12, layout-v13 ?

Hope my question is not confusing, i just dont know how to put my question any other way.

Thanks

Camellia
  • 141
  • 14
Akash
  • 367
  • 9
  • 21
  • Did you take a look at this? http://stackoverflow.com/questions/4185507/layout-for-tablets-in-android – 0gravity Aug 23 '12 at 13:42
  • Yes I did @0gravity , the problem remains the same, I will have duplicate layouts. I just want a folder where can treat all kinds of tablets, dont want to distinguish their size, api level or density. – Akash Aug 23 '12 at 13:58
  • 1
    "...dont want to distinguish their size, api level or density" Then how? I don't know what else would be different between a phone an a tablet bessides the resolution. I guess you can ask the user if he is using a tablet, and then have an if statement that would use the xml file that you want. – 0gravity Aug 23 '12 at 14:05

2 Answers2

13

If you use layout-v11 it will be used for all versions >= 11 unless a higher version is specified (e.g. layout_v14). So you should only need to make the one folder, layout-v11.

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274
  • Thanks, and taking all the answers in consideration, I will use screen size to distinguish. Thanks – Akash Aug 23 '12 at 14:09
3

Don't forget that you can have a 4" android device with API lvl 14. So using API version to distinct tablets and phones is not a good way.

Prefer the distinction with screen resolution. A good post about it is on the Android developers blog:

http://android-developers.blogspot.fr/2012/07/getting-your-app-ready-for-jelly-bean.html

Aerilys
  • 1,628
  • 1
  • 16
  • 22