8

I need to support an application for bith mdpi, hdpi and xhdpi mobiles and 7' and 10' tablets I have to admit that I'm a bit lost.

So far I only did the tablet version and what I did is :

  • one single folder called "layout"
  • 3 different folders called "drawable-sw600dp", "drawable-sw800dp" and "drawable-sw1200" containing images of 600px large, 800px large and 1200px large.

I have the impression that I messed it up and that I should have the created standard "drawable-mdpi", "drawable-hdpi" and "drawable-xhdpi" folders.

But if I do so :

  • in which folder do I have to put the images for the tablets? xhdpi only?
  • how large (in px) should be the images for the tablets?
  • how large should be the images for the mobiles?
  • and last but not the least : how to have to name the "layout" folders to have a different version for mobiles and tablets?

I already read the Android recommendation like a 1000 times and I am still confused...

EDIT 1

This paragraph from Android website answered my question "how to have to name the "layout" folders to have a different version for mobiles and tablets?"

EDIT 2

Regarding the drawable folders, for mobile phones, it seems quite clear that I have to create 3 folders this way :

  • drawable-mdpi containing 320px-width images
  • drawable-hdpi containing 480px-width images
  • drawable-xhdpi containing 720px-width images

Still remains the question of how to name the different drawable folders for supporting tablets.

thomaus
  • 6,170
  • 8
  • 45
  • 63

2 Answers2

14

so this would be my answer.

Layouts -> 2 folders :

  • "layout" (or "layout-sw320dp") for mobiles
  • "layout-sw600dp" for tablets

Drawables -> 5 folders :

  • "drawable-mdpi" for mobiles, containing 320px-width images
  • "drawable-hdpi" for mobiles, containing 480px-width images
  • "drawable-xhdpi" for mobiles, containing 720px-width images
  • "drawable-sw600dp" for 7'' tablets, containing 600px-width images
  • "drawable-sw720dp" for 10'' tablets, containing 720px-width images

Any better response than this one is welcome!

thomaus
  • 6,170
  • 8
  • 45
  • 63
  • Hi, i just want to ask you something for just my knowledge. i am using 7 drawables like drawable-hdpi, drawable-large-mdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, drawable-xlarge-mdpi, drawable-xxhdpi. am i going right or wrong? can you please help me to increase my knowledge? thanks in advance. waiting for helpfull response.. :) – Ajay Oct 16 '13 at 13:16
  • I think you should ask a dedicated answer on StackOverflow for this topic. – thomaus Oct 17 '13 at 16:15
  • Note that `layout-sw320dp` style is said to work from API level 13 (Android 3.2). That makes this style limited in phone support, that usually is to go to Android API level 8 (Amdroid 2.2) – Paul Verest Sep 11 '14 at 11:40
  • so different layout are also very important? I have one one layout for activity and it works perfect for mobile and table, how can I bypass creating two layouts and still be design tabled approved? Also what size width px means? We may have small icons which should not be that big like 600px or 720px but you say is it minimum for any image? – user25 Jul 15 '18 at 13:11
  • and what is supposed to solve problem **Your APK should include custom drawables assets for common tablet screen densities** ? – user25 Jul 15 '18 at 13:14
3

Because LDPI is barely used you should make 3 different sizes of images for mobiles.

Lets say you have an image which is 50x50 DP.

MDPI = 50x50PX

HDPI = 75x75PX (x1.5)

XHDPI = 100x100PX (x2.0)

You can create even more folders like: drawable-xlarge-xhdpi and drawable-xlarge-hdpiand put images you need for the tablets in there. I believe xlarge was for 10-inch? So you might end up with about 9 different sizes. 3 for mobile, 3 for 7' and 3 for 10'. Tablets also have pixel densities!

Right click your project in Eclipse -> New -> Other -> Android XML File

And then you choose Drawable as a recourse type to make drawable folders for example.

Below is a screenshot of how this looks. It's really useful!

Also see list of displays by pixel density

enter image description here

Using this you make folders that will look like this. large is 7', xlarge was 10' (I think).

/res/drawable-large-mdpi

/res/drawable-large-hdpi

/res/drawable-large-xhdpi

/res/drawable-xlarge-mdpi

/res/drawable-xlarge-hdpi

/res/drawable-xlarge-xhdpi

7 inch Android tablets are HDPI and large.

Check the table here and read about large/xlarge/small etc.

Edward van Raak
  • 4,841
  • 3
  • 24
  • 38
  • Thanks man, but this is not what I'm looking for. Basically my question is : how many different sizes of images (in pixels) do I need to support android devices and tablets? – thomaus Mar 01 '13 at 12:53
  • 3 different image sizes for 7' and 3 different ones for 10'??? Are you sure? What size would they be then? (btw, please check my edits) – thomaus Mar 04 '13 at 09:35
  • You don't have too but tablets obviously have more space so you might want to create bigger art assets to fill that space if needed. The size depends on your layouts. If it's just icons or something there is no need for this. – Edward van Raak Mar 04 '13 at 09:46
  • I don't get your answer. I just want to know how to name the drawable folders for tablets (and what images should I put in them)? This is perfectly clear for mobiles and nowhere said in Android doc. – thomaus Mar 04 '13 at 10:04
  • That's why I told you to use the wizard to generate the folders. Don't you see the "/res/layout-xlarge-xhdpi" in the screenshot? You can generate any required folder name this way. – Edward van Raak Mar 04 '13 at 10:21
  • small, medium, large and xlarge qualifiers should not be used for tablets, see http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts – thomaus Mar 04 '13 at 11:13
  • this did not worked for me..I have created folders in the same way, also created layout-sw600dp-land & layout-sw720dp-land, targetting 7" and 10" tablets. But not working – Sanal Varghese Nov 11 '13 at 09:03
  • @EdwardvanRaak you comment doesn't make sense (wizard), of course we can generate anything (~1000 things) but which one will work for author's question?! – user25 Jul 15 '18 at 13:13