Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i made the layout that will work in both Tablet and phone?

I made the layout from xml with on tablet layout of emulator size. But when open on same layout on android phone device then every thing distorted, So can i make a xml layout that will work fine in both of device phone and tablet also. Please suggest me, appreciate your answer.

like image 413
Sunil Kumar Avatar asked Jun 28 '13 05:06

Sunil Kumar


1 Answers

Make your resource like this.

res/layout/my_layout.xml // layout for normal screen size ("default")

res/layout-small/my_layout.xml // layout for small screen size

res/layout-large/my_layout.xml // layout for large screen size

res/layout-xlarge/my_layout.xml // layout for extra large screen size

res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/drawable-mdpi/my_icon.png // bitmap for medium density

res/drawable-hdpi/my_icon.png // bitmap for high density

res/drawable-xhdpi/my_icon.png // bitmap for extra high density

For more reference. reference1.

Add this in your manifest.xml

<supports-screens
            android:smallScreens="true"
            android:normalScreens="true"
            android:largeScreens= "true"
            android:anyDensity="true"
    />

Hope this will help you.

like image 68
Nirmal Avatar answered Oct 13 '22 12:10

Nirmal