Supporting multiple screen size - Android

Sniper picture Sniper · Nov 21, 2013 · Viewed 17.7k times · Source

I am going to develop new application in Android. This application should only work in portrait (even for tablet). Also the UI and layout design should be similar on phones and tablet. We can't change the layout design for tablet as it has huge area to use. We have to stretch all the images to match phones. We can use nine patch. But I am little bit confused of using images in multiple drawables.

As per my analysis (may be wrong.. : ) ) the screens are divided into density and sizes. We can use the scaling ratio of 3:4:6:8. But this ratio is based on the density. But in my case I have to stretch the entire UI to fill the Tablet screen.

So what are the drawables that can be used for a app like this which can support multiple devices. And what are the screen sizes for which we have to design.

And this application needs nearly 100 layouts. So I am planning to maintain single layout and designing the layout using weight for each layout instead of using dimension.

Also if I used multiple APKs to support different screen size what are the drawables used to support 1. Small and Normal 2. Large 3. Xlarge

Answer

znat picture znat · Nov 21, 2013

I just did something very similar. To stretch the app without creating new layouts I used dimensions set in XML

res/values/dimensions.xml
res/values-sw600dp/dimensions.xml -> 7+ inches
res/values-sw720dp/dimensions.xml -> 10+ inches

Dimensions are resources files:

<dimen name="default_padding">11dp</dimen>

You can increase the dimensions by about 30% in the 600 and 720 file. Then simply used @dimen/default_padding in your layout and it will be scaled

Regarding images, either you make sure you have all your assets in all densities, or you set fixed size to you ImageView's and appropriate scaleType