1

I am absolutly new in Android development (I am developing my first app so be patient) and I have the following doubt.

I have to insert a picture as background of a view into my application and this image have to be correctly shown on all the different devices having different screen size.

So I found this article: http://www.survivingwithandroid.com/2012/07/how-to-support-multiple-screen-in.html

My doubt is: what exactly I have to do in my project?

I think that I have to do the following steps (but I am absolutly not sure of it so I am asking to you):

1) Into the res folder of my project I create the following subfolder: drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi

2) Then I use Photoshop to change the density of my picture and so I put the 120dpi version of my picture into the drawable-ldpi folder, the 160dpi version of my picture into the drawable-mdpi and so on.

Is it my reasoning correct? It ensure that my picture it is displayed at the same size on different screens?

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • 1
    Related, http://stackoverflow.com/questions/13024272/android-background-image-size-in-pixel-which-support-all-devices and http://stackoverflow.com/questions/1400782/android-scale-a-drawable-or-background-image – Arjan Jun 12 '16 at 16:37
  • Yes you are right. You need 144x144 px, 96x96, 72x72 and 48x48 for respectively xhigh, high, medium and low density. That means a low density pictures must be doubled for a high version of it. If ldpi has a 120x120 px pictures, hdpi must contains the same pictures with the same name but 240x240 dimensions – Alexandre Martin Jun 12 '16 at 16:39
  • @AlexandreMartin Ok I think that I am missing something: I have also to change the dimension of the img or only the dpi? – AndreaNobili Jun 12 '16 at 16:40
  • I updated my comment – Alexandre Martin Jun 12 '16 at 16:42
  • Change image dimensions and put them in the right density subfolder of drawable – Alexandre Martin Jun 12 '16 at 16:43
  • @AlexandreMartin I still can't understand...have I to change the image dimension or the image dpi? – AndreaNobili Jun 12 '16 at 16:59
  • 1
    The image dimension. DPI will be handled by the device, but you have to put your pictures in the appropriate DPI folder to have it done correctly. – Alexandre Martin Jun 12 '16 at 17:01

0 Answers0