Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android supporting all tablets - categorize drawables and layouts

I have seen many thread discussing this problem in stackoverflow (like this, this and this), and I have read the documentation about supporting multiple screens, and designs. But I am still not clear about the folder structure for drawables and layout for different screens

I am working on an app that support android phone and tablets. And my project showing some images, which need to be shown in good quality in all possible android devices. And I need to tell my designer to design for all these resolutions.

From the documentation it seems I should add drawables for following resolutions (drawable folder name is given at the end),

1) 240 x 320  - Phone LDPI  -> drawable-ldpi

2) 320 x 480  - Phone MDPI  -> drawable-mdpi

3) 480 x 800  - Phone HDPI  -> drawable-hdpi

//Now for tablets

4) 1024x600   - Tablet LDPI -> ??

5) 1280x800   - Tablet MDPI -> ??

6) 1536x1152  - Tablet HDPI -> ??

7) 2560x1600  - Tablet XHDPI-> ??

From supporting multiple screens documentation, it seems I can use folders like

1) drawable-sw600dp  ( a 7” tablet (600x1024 mdpi).)
2) drawable-sw720dp   (a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

But what about tablets with resolutions in the range of 1536x1152, 2560x1600 etc.. the 10' resolution range (720 x 1280 etc)seems small for them.. My client has a Nexus 10 with resolution 2560×1600 and I want my app to look perfect on it..

I know about, nine patch images, layout using wrap_content and other good practices like that. But for this project, I have some images which, as per requirement, should be seen lazer sharp on all common screens, and I need several versions of those images at least in my bundle.

So what and what resolutions should I mention to the designer? And how can I categorize them in bundle giving correct folder name.

like image 435
Krishnabhadra Avatar asked Jan 04 '13 04:01

Krishnabhadra


2 Answers

Actually Tablets are categorized by size not by dpi, i.e 7" tab is drawable-large while your 10" tab is drawable-xlarge. And now you can again categorized by dpi like drawable-large-hdpi which means it is a Tab of 7" which having High Density.

you can use SW smallest width concept to target that, see Application Skeleton to support multiple screen and make calculation for the same.

Tablet Tablets are categorized into two size.

7" (1024X(600-48(navigation bar))) = 1024 X 552 (drawable-large)
10" (1280X(800-48(navigation bar))) = 1280 X 752 (drawable-xlarge)

and for 2560x1600 calculate SW dp with formula

px= Device's width
dpi= Device's density

formula given

px = dp * (dpi / 160)

interchange formula if you have px's value

dp = px / (dpi / 160)

so drawable-swxxxdp will do the job

like image 61
Mohammed Azharuddin Shaikh Avatar answered Sep 27 '22 18:09

Mohammed Azharuddin Shaikh


AFAIK there are two kinds variables for device display : pixel density and screen dimensions. Both are theoretically independent, though in market both vary together from low end to high end devices.

Pixel density demands for different bitmap resolutions and level of detail (36X36 to 96X96 icons for example) .

Screen dimensions demand for better use of real estate ( Multi activity layout for phones, combined fragmented layout for tablets, for example). Not as important as pixel density, but good to have, because tablet users might find a phone layout too bland, and waste of screen space.

So:

  • To cover most pixel densities you will have to have different versions of drawables : ldpi,mdpi,hdpi and xhdpi. Prefer nine-patch drawables, these are a lot better at fitting everywhere.

  • To cover most screen sizes you will have to have different layout arrangements, and a responsive layout design for small,large and xlarge values. Also, different layouts for portrait, and landscape orientations are good to have sometimes.

  • Android lets you mix configuration combinations too. E.g. drawable-large-hdpi etc.

  • Avoid hard coded pixel co-ordinated and dimensions at all costs, use density or percentage.

  • Its Way better to have one flexible nine-patch drawable than to have different drawables for different screen sizes.

like image 37
S.D. Avatar answered Sep 27 '22 18:09

S.D.