Creating Multi-screen Support App Android
Solution 1:
Try out like:
- layout-sw320dp
- layout-sw480dp
- layout-sw600dp
- layout-sw720dp
instead of
- layout-small,
- layout-large etc...
Solution 2:
Please refer below link:
http://developer.android.com/guide/practices/screens_support.html For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens. you could use different size of the layout files in res folder and also vary for drawable images based on the density..
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
<compatible-screens><screenandroid:screenDensity="ldpi"android:screenSize="small" /><screenandroid:screenDensity="mdpi"android:screenSize="normal" /><screenandroid:screenDensity="xhdpi"android:screenSize="large" /><screenandroid:screenDensity="xhdpi"android:screenSize="xlarge" /></compatible-screens>
And followed by any activity use this lines..
android:configChanges="orientation|screenSize|keyboardHidden"
Solution 3:
In values folder naming convention like layout-small
only works for devices with api version less than 3.1
. You should create values file with naming like layout-sw600dp
for api level greater than 3.1. read this http://developer.android.com/guide/practices/screens_support.html3.1api
like this you should create layout-sw600dp, layout-sw720dp for each type of devices.
layout-sw600dp means this layout works for devices with smallest width of 600dp
If you have layout-600dp and layout-sw720dp folders. first layout folder works for devices with smallest width of 600dp(7 inch tablet) to 720dp and second works for devices with smallest width above 720dp(10 inch tablet).
If your minimum required version is above 3.1 you don't need have layout-small, layoutxLarge folders. otherwise you have to consider both type of layout fromats.
Solution 4:
Here is a quick checklist about how you can ensure that your application displays properly on different screens:
Use wrap_content, fill_parent,
or dp
units when specifying dimensions in an XML layout file.
Do not use hard coded pixel
values in your application code(.java
files).
Do not use AbsoluteLayout
(it's deprecated in Android 1.5
). You should instead use RelativeLayout
, which uses relative positioning to lay out its child views.
Supply alternative bitmap drawables for different screen densities.
Take time and read these screens_support or to get a better idea see How Android Finds the Best-matching Resource so that you know where to place your resources.
Post a Comment for "Creating Multi-screen Support App Android"