How to prepare layout,drawable folders for 7",10" android tablets for both landscape and portrait?
Solution 1
The recommended way is to use layout-swxxdp
qualifier. If you need to differentiate landscape/portrait
res/layout-sw600dp/ # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/ # For 10” tablets (720dp wide and bigger)
res/layout-sw600dp-port/ # For 7” tablets in portrait (600dp wide or bigger)
res/layout-sw720dp-port/ # For 10” tablets in portrait (720dp wide or bigger)
Solution 2
try below :-
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
also see below :-
Solution 3
You are naming the folders in the wrong way. In Android, there is a rule or order in which you name your resource folders. You should provide your qualifier names in that order.
Check this documentation table on providing resources. Your should name your folders in the order provided in the table.(Its better if you read the whole page, because it'll give you a better understanding in providing resources)
Here you should name the folders as
layout-large-port-hdpi
drawable-large-port-hdpi
For preparing the resource folders for tablets, you can use either the screen size attribute or shortest width attribute.
For e.g
If you use screen size attribute, you can name folders like
layout-large-... (for 7" devices)
layout-xlarge-... (for 10" devices)
I you use shortest width attribute, you can use
layout-sw600dp-... (for 7" devices)
layout-sw720dp-... (for 10" devices)
Remember shortest width attribute works only on devices from 3.2 (API 13).
user2376732
Updated on July 29, 2022Comments
-
user2376732 over 1 year
I have prepared my drawables for 7" tablets as (Nexus 7)
drawable-large-hdpi-port layout-large-hdpi-port
I am getting errors while doing this. I didnt understand where I am doing wrong.
I want to prepare layouts for both landscape and portrait for both 7", 10" tablets
-
Lester over 7 yearsWhy do you need -port suffix?
-
M. Usman Khan almost 7 yearswill this only work for screen size >= 7" ? will it be used for a 4" screen that is 600dp wide?
-
schlenger over 5 years@Lester this is for portrait only - see here developer.android.com/training/multiscreen/screensizes