I am new in android, and want to design the layout which run in all screens of the android phone and tablet too ? Is their is a way to do this ?
-
1Documentation covers it very well http://developer.android.com/guide/practices/screens_support.html – Kuffs Dec 08 '11 at 09:04
-
http://www.google.co.in/search?gcx=w&sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=to+support+different+screen+size+in+android – Uttam Dec 08 '11 at 09:20
-
go through the link . http://developer.android.com/guide/practices/screens_support.html – user493244 Dec 08 '11 at 09:21
-
Which layout folders i need to create for Nexus 9 and Nexus 10 devices? – Dhaval Khant Jun 15 '15 at 10:29
5 Answers
You need to create different layout for diff screen size. Support all screen you need to create following layout:
Low density Small screens QVGA 240x320 (120dpi):
layout-small-ldpi (240x320) layout-small-land-ldpi (320x240)
Low density Normal screens WVGA400 240x400 (x432) (120dpi):
layout-ldpi (240 x 400 ) layout-land-ldpi (400 x 240 )
Medium density Normal screens HVGA 320x480 (160dpi):
layout-mdpi (320 x 480 ) layout-land-mdpi (480 x 320 )
Medium density Large screens HVGA 320x480 (160dpi):
layout-large-mdpi (320 x 480 ) layout-large-land-mdpi (480 x 320)
Galaxy Tab ( 240 dpi ):
layout-large (600 x 1024) layout-large-land (1024 x 600)
High density Normal screens WVGA800 480x800 (x854) (240 dpi):
layout-hdpi (480 x 800) layout-land-hdpi (800 x 480)
Xoom (medium density large but 1280x800 res) (160 dpi):
layout-xlarge (800 x 1280) layout-xlarge-land (1280 x 800)
Also add following code in .manifest
file:
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />

- 34,476
- 22
- 104
- 118

- 2,467
- 2
- 16
- 24
-
1
-
@DhavalKhant it didn't work. Do you know if can I use it as values-w540dp-h960dp instead layout-w540dp-h960dp? – gandarez Jun 19 '12 at 23:16
-
@Gandarez its example. Here values are given to dp and screen resolution(540x960) is in pixel so first convert resolution into dp. then use layout-wXdp-hYdp. – Dhaval Khant Jun 20 '12 at 05:55
-
-
-
@DhavalKhant I tried just values-360dp and it didn't work. :( Do you know if I have to change to layout-360dp? – gandarez Jun 25 '12 at 15:40
-
-
Thanks for the structure. I have one more quesetion: the layout folder is still there, besides these folders, right? So if I want to edit the normal size screen's layout, which folder should I edit in? layout or layout-hdpi if it's a hdpi resolution device? Thank you! – Iam619 Aug 17 '12 at 18:35
-
Hello, here how many folder should I create for drawables? and If I need to specify dpi for layout-xlarge (800 x 1280) then how can I specify? – user861973 Aug 29 '12 at 13:21
-
@user861973 you need to create one folder i.e. drawable-xlarge. Put all images into this folder for xlarge screen. – Dhaval Khant Aug 29 '12 at 13:25
-
@user861973 you need to create large size images for 10" inch tablet. – Dhaval Khant Aug 30 '12 at 04:35
-
but if we consider 75%(ldpi) 100%(mdip,standard) 150%(hdpi) 200%(xhdpi). then what should be size for 10'' inch table? – user861973 Aug 30 '12 at 04:39
-
@user861973 10" inch table resolution is 800 x 1280 and screen DPI is 160 (mdpi). – Dhaval Khant Aug 30 '12 at 04:43
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15998/discussion-between-user861973-and-dhaval-khant) – user861973 Aug 30 '12 at 04:51
-
yes.I have made image for mdpi is 30px X 30px. but it is not enough for 800x1280 screen. for 320x480 it is fine. but not for resotluion 800x1280 – user861973 Aug 30 '12 at 05:12
-
hi , just seen your post, what will be the layout folder name for hd Devices(720*1280) like samsung galaxy s3, – Raheel Sadiq Oct 15 '12 at 09:25
-
-
I have around 10 activities so according to this i need to create 10x14 = 140 layout? :O – ruben May 08 '13 at 04:34
-
Nice one. but what can i do for different `textSize` of `TextView`? is it better? – Pratik Butani Sep 18 '13 at 05:31
-
@Dhaval Khant : r you manage 540x960 screen layout ? if yes than which way ? – Harshal Kalavadiya Aug 02 '14 at 07:10
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
You should probably read this:

- 19,893
- 17
- 73
- 130
In addition to the traditional supports-screens parameters refer to the new Size Qualifiers launched in 3.2
Using new size qualifiers
The different resource configurations that you can specify based on the space available for your layout are summarized in table 2. These new qualifiers offer you more control over the specific screen sizes your application supports, compared to the traditional screen size groups (small, normal, large, and xlarge).
Table 2
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).
Using the size qualifiers from table 2, your application can switch between your different layout resources for handsets and tablets using any number you want for width and/or height. For example, if 600dp is the smallest available width supported by your tablet layout, you can provide these two sets of layouts:
res/layout/main_activity.xml # For handsets res/layout-sw600dp/main_activity.xml # For tablets
<manifest ... > <supports-screens android:requiresSmallestWidthDp="600" /> ... </manifest>

- 11,190
- 2
- 32
- 22
If you want to use only one layout xml that scales with the screen size you can use the sdp sdk.
Add the sdp sdk:
dependencies {
compile 'com.intuit.sdp:sdp-android:1.0.2'
}
And you would be able to define a scalable TextView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A scalable text"
android:textSize="@dimen/_12sdp" />

- 2,736
- 24
- 26
if you are using android 1.6
then try this for different layout as i have used it:
- if width - height - density :- 320 - 480 - 160 then res/layout folder name:- (layout-medium-mdpi)
- if width - height - density :- 480 - 800 - 160 then res/layout folder name:- (layout-large-mdpi)
or if width - height - density :- 480 800 240 then res/layout folder name:- (layout-medium-hdpi)
it works....

- 223,805
- 18
- 296
- 547

- 11
- 2