Android supporting all tablets - categorize drawables and layouts
Asked Answered
C

5

13

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.

Comptom answered 4/1, 2013 at 4:33 Comment(1)
Check out the wordpress app. it might give you some idea on how to handle diff screens android.trac.wordpress.org/browser/trunkAlexanderalexandr
L
19

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

Libbielibbna answered 4/1, 2013 at 4:42 Comment(6)
and also see the developer site DeclaringTabletLayoutsLibbielibbna
So I would say, I should tell the designer to design for 1) 1024 x 768 (drawable-large folder) 2) 1280 x 800 (drawable-xlarge folder) 3) 2560x1600 (use drawable-xlarge-xhdpi folder). Will it covers almost all screens?Comptom
No, its very difficult to cover all Tab screen because there are many. see my updated answerLibbielibbna
One more doubt, what is the navigation (status bar height?) of a nexus 10 tab (I mean any tab with 2560 x 1600) resolution in portrait/landscape mode? Any way to find it using any calculation?Comptom
had done some R&D(month ago) seems it is the same but not very sure about nexus 10 Tab, will back to you if any new update availsLibbielibbna
Here's my current implementation. I have 3 set of folders for drawables. drawable, drawable-sw600dp-mdpi (x 4 densities), drawable-sw720dp-mdpi(x 4 densities) for phone, 7" and 10" tabs respectively. Total of 12 folders of images. but my 10" galaxy tab GT-P7500 (1280x800) seems to pick up images from sw720dp-XXHDPI folder instead of sw720dp-MDPI folder. However when i use only 1 set of folders without swXXXdp qualifiers its picking up correctly from DRAWABLE-MDPI folder . What could be the possible issue ?Pretrice
O
2

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.

Onstad answered 4/1, 2013 at 4:52 Comment(0)
C
2

We can also use xxhdpi for drawables like drawable-xxhdpi

xxhdpi (480dpi, Android 4.1 or later)

Or refer "Android Tabular Column" in the follwing link

http://en.wikipedia.org/wiki/Smartphone

Culbert answered 1/4, 2013 at 7:20 Comment(0)
C
1

What I have come to use is:

  • one layout folder (or second one: layout-land)
  • a few values folders with dimens.xml (-hdpi, -large, -xlarge) for different sizes, fonts etc.
  • drawables: -hdpi with most images, they scale down for all the phones; -large for 7" tablets; -xlarge for 10" tablets. Or just -hdpi and -large.

I might verify this approach, i.e. use -sw600dp and -sw720dp but for now it works.

Crossbill answered 14/2, 2013 at 8:36 Comment(0)
V
-1

Hello i think android drawable resolution is-

10" - 1280 X 800

7" - 1024 X 600

xhdpi - 960 x 720

hdpi - 800 X 480

mdpi - 480 X 320

Vandalize answered 18/10, 2013 at 4:40 Comment(1)
Density has very little to do with resolutionRoarke

© 2022 - 2024 — McMap. All rights reserved.