Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout for tablets in Android

I would like to create different layouts for tablets and handsets in Android. Where should I put the layout resources in order to make this differentiation?

like image 258
hpique Avatar asked Nov 15 '10 14:11

hpique


People also ask

How do I set Android layout to support all screen sizes?

To ensure that your layout is flexible and adapts to different screen sizes, you should use "wrap_content" and "match_parent" for the width and height of some view components.

How can I make Android apps compatible with all screen sizes?

Use Relative layouts, draw 9 images. And for high quality apps you may create different different layout XMLS for all 4 screen sizes. http://developer.android.com/guide/practices/screens_support.html Use this link for more info. Show activity on this post.


2 Answers

I know this is an old question, but for the sake of it... According documentation, you should create mutiple asset folders like this

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width) res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger) res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger) 
like image 147
urSus Avatar answered Oct 06 '22 13:10

urSus


If you are using Fragment concept in the code(means Multi-Pane layout) then its best to use wdp instead of swdp

res/layout-w600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger) res/layout-w720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger) res/layout-w600dp-land/main_activity.xml   # For 7” tablets in landscape (600dp wide and                  bigger) res/layout-w720dp-land/main_activity.xml   # For 10” tablets in landscape (720dp wide and bigger) 

Refer the table for understanding wdp

Table 2. New configuration qualifers for screen size (introduced in Android 3.2). In the following link http://developer.android.com/guide/practices/screens_support.html

like image 40
Sakthimuthiah Avatar answered Oct 06 '22 12:10

Sakthimuthiah