I want to support my android screen in multiple screen sizes but i can do it with maintaining multiple xml layout file\'s
but according to requirement it i supposed to b
You can define multi dimen files, and add dimensions of each view according to screen size in there. You can find detailed answer here
A set of six generalized densities:
Here is the official docs
Well that depends on your code
Drawables
Use every DPI
FolderLook at these Links
1)https://developer.android.com/training/multiscreen/screensizes.html
2)How to support different screen size in android
3)Supporting multiple screen size - Android
If you want to use single layout and that should support all the screens like ldpi, , mdpi, hdpi, x-hdpi, xx-hdpi then you have to use weight in your layout that will handle screen size for all the screens.
Here’re a few things:
If you want to divide the space equally between Views with the same weight – set 0dp as Views’ width.
If you set View width to wrap_content – size of the Views will depend on weight and content inside each View.
Create three different Layouts Folder
in your res
folder for all devices and use the dimensions accordingly.
Generic Layout Folders
res/layout-small
res/layout-normal
res/layout-large
res/layout-xlarge
After you are done with making your Normal/Medium Layouts follow these steps:
For converting Values
0.75 - ldpi (small) //mdpi dimens *0.75
1.0 - mdpi (normal) //First create these dimensions
1.5 - hdpi (large) //mdpi dimens *1.5
2.0 - xhdpi (xLarge) //mdpi dimens *2.0
For Example
android:layout_width="66dip" //in normal
android:layout_width="100dip"//in large 66*1.5=100(approx)
android:layout_width="52dip" //in small 66*0.75=52(approx)
Also new Qualifier has been introduced - SmallestWidth - AvailableScreenWidth - AvailableScreenHeight
read more about it here https://developer.android.com/guide/practices/screens_support.html
I hope this helps.
May be you can try below library which manages all the screen size resolution automatically.
compile 'com.intuit.sdp:sdp-android:1.0.4'
You need to just add the dependency in your build.gradle file and you are done.
You need to specify like:
android:layout_height="@dimen/_10sdp"
Instead of usual:
android:layout_height="@dimen/10dp"
There are three ways to do this :
1) Put your images and icon in different drawable
folder including drawable-mdpi
, drawable-hdpi
, drawable-xhdpi
, drawable-xxhdpi
, drawable-xxxhdpi
which will be access image from particular folder based on screen resolutions. Don't apply fixed values everywhere for image. Fixed dimensions can be vary with different device and image will be looked stretch. So use wrap_content
2) Set dimensions in dimens.xml
for different values
folder.
values-mdpi\dimens.xml
values-hdpi\dimens.xml
values-xhdpi\dimens.xml
values-xxhdpi\dimens.xml
values-xxxhdpi\dimens.xml
3) Use LinearLayout
with proper using of android:layout_weight
.