7
Android Studio 1.3

Hello,

I have taken some pictures from my Nexus 5 phone. I would like to use one for as a header that is loaded into a imageview.

However, I am not sure about the scaling and which drawable-xhdi, drawable-xxhdi etc, it should go in.

The picture I have currently is:

Width: 3200 pixels
Height: 2368 pixels
Size: 2.4 MB
file type: jpg

I have gimp photo edit tool that I can compress into a png file to reduce the size. But I am not sure how can I make the picture look good on other screen densities. Which drawable folder would I have to put each one in?

Many thanks for any suggestions,

ant2009
  • 27,094
  • 154
  • 411
  • 609
  • 1
    possible duplicate of [Android: Scale a Drawable or background image?](http://stackoverflow.com/questions/1400782/android-scale-a-drawable-or-background-image) – Pratik Butani Aug 22 '15 at 04:28
  • i would just like to know you want to make it look good in only mobile phones between 4" -6"inches or you are targetting to tablets or not?? – SID --- Choke_de_Code Sep 03 '15 at 06:08

4 Answers4

10

1st of all, you should know there is a limit on image size :

OpenGl maximum size is 2048x2048 or else it throws an error: Bitmap too large to be uploaded into texture.

2nd you must consider, what are devices you are targetting for. There are different qualifiers in android:

Screen size: Actual physical size, measured as the screen's diagonal. For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra-large.

Screen density The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into six generalized densities: low, medium, high, extra-high, extra-extra-high, and extra-extra-extra-high.

  • small and normal size - Handsets
  • large size - 7' tablets (e.g. sw600 - smallest width 600dp)
  • xlarge size - 10' tablets (e.g. sw720 - smallest width 720dp)

3rd look at Android Dashboard.

Dashboard 03.09.2015

Quick look reveals, that are few ldpi and almost none xxxhdpi devices. What does it mean? You don't need to provide resource for those folder. But do as you like.

Note: You do not need to provide xxxhdpi assets for all your app's images.

4th Look at your application and find out the maximum size:

So if your image is going to be a header, I assume it will match_parent -> Let's say, you are designing your app to work on screen resolutions 1920*1080 (h*w) and lower. Now you see first important step. If your image matches_parent and parent is maximum 1080px wide, you don't need 3200 px wide image!

5th Resize the image using some tool like 9-Patch-Resizer or Android Asset Studio and add it to your drawable folders

6th Test it on devices and check if the image quality is good enough. On tablets, you might consider to use drawable-large and drawable-xlarge folder.

  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Community
  • 1
  • 1
Vojtěch Pešek
  • 1,070
  • 8
  • 25
3

first you should make a decision about how big the picture size you want in dp dimension.because dp is a device independent dimension.

for example, if you want you image to be 200 * 100 dp. then the picture you put in the different drawable folder should be the size below:

drawable-ldpi    150 * 75    px 
drawable-mdpi    200 * 100   px
drawable-hdpi    300 * 150   px
drawable-xhdpi   400 * 200   px
drawable-xxhpi   600 * 300   px


3 : 4 : 6 : 8 : 12
mdpi means 1 dp = 1px
Iamat8
  • 3,888
  • 9
  • 25
  • 35
HappyOrca
  • 79
  • 4
2

Take a look at the documentation here: http://developer.android.com/guide/practices/screens_support.html#range

Quote:

A set of six generalized densities:

  • ldpi (low) ~120dpi
  • mdpi (medium) ~160dpi
  • hdpi (high) ~240dpi
  • xhdpi (extra-high) ~320dpi
  • xxhdpi (extra-extra-high) ~480dpi
  • xxxhdpi (extra-extra-extra-high) ~640dpi
Gergely Kőrössy
  • 5,620
  • 3
  • 28
  • 44
2

If it is nexus5 it resolution is 1080 x 1920 pixels (~445 ppi pixel density)

As per set of generalized density as per android developer console

xhdpi (extra-high) ~320dpi

xxhdpi (extra-extra-high) ~480dpi

so nexus 5 will take drawable-xxhdpi for images