Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to categorize android layout in to small,medium,large,x-large screen?

Tags:

android

layout

I created 4 different layout files and placed it in layout , layout-small,layout-large,layout-xlarge. folder and TESTED IN QVGA,HVGA,AND WXGA EMULATOR. But it is only taking the default layout(which i placed it in layout folder)for all emulator. Any solution?

like image 670
vnshetty Avatar asked Jul 11 '11 09:07

vnshetty


People also ask

How do I make my layout different screen sizes?

Use “wrap_content” and “match_parent” 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.

What screen size should I design for Android?

I recommend designing at 360x640 for Android and 375x667 for iOS. Unless you want to showcase your design in a modern and trendy Device Mockup, for example, iPhone 11 Pro or Samsung Galaxy S10+, or your target userbase has a different screen size.


3 Answers

Have you given the same name to all layout file, for e.g. main.xml, i mean to say give the same name to xml layout files and places in the particular folder. It will automatically managed by Android itself, programmer need not to bother about the same.

I made my comment as answer as this is right as per vnshetty's comment above. So that other answers may not be selected as accepted wrongly.

like image 95
Paresh Mayani Avatar answered Nov 03 '22 00:11

Paresh Mayani


To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:

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).

For other cases in which you want to further customize your UI to differentiate between sizes such as 7” and 10” tablets, you can define additional smallest width layouts:

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 31
Aarun Avatar answered Nov 03 '22 00:11

Aarun


http://developer.android.com/guide/topics/resources/providing-resources.html

layout-medium does not exist - should use layout-normal instead

Also are you specified min api version? it will works only if you specify <uses-sdk android:minSdkVersion="4" /> or higher in your manifest file.

like image 42
CeKup Avatar answered Nov 03 '22 00:11

CeKup