Welcome Android Developpers

Welcome Android Developpers
My name is Mathias Séguy, I am an Android Expert and Trainer and created the Android2EE company.

For full information, it’s here : Android2EE's Training
You can meet me on Google+, follow me on Twitter or on LinkedIn

Monday, November 14, 2011

Define your pictures for all densities : ldpi,mdpi,hdpi (and xhdpi if you target tablet)

Bandeau Conference

In my previous post we understood why we need to declare our images in the layout file in dp (density-independent pixels). Thus, whatever the density of the screen, the image is the "same" size.
The corollary is: if you define/declare your pictures (in the folder drawable) once regardless of the density, they'll appear coarse in hdpi (and also in ldpi).

Thus, each frame (especially your icons) should be designed in ldpi, mdpi and hdpi.
To do this, you must resize each picture by applying the following rule:
For an picture in mdpi of size n * m , you must set a hdpi picture of size (n * 1.5) * (m * 1.5) and an picture of size (n * 0.75) * (m * 0.75) for the ldpi. So you should always set 3 image sizes for each of your images. You should also drop each of those pictures in the right drawable folder (drawable-mdpi for mdpi, drawable-hdpi for hdpi and so on).
Then your GUI will be valid for all densities.
Finally, if you want to program for tablets, remember that the xhdpi is available for this density, so you must also draw a new image of size (2 * n) * (2 * m).
The ratio to remember this is: 3 | 4 | 6 | 8 (ldpi | mdpi | hdpi | xhdpi)

The source of this post: http://developer.android.com/guide/practices/screens_support.html:
"Alternative drawable

Almost Every Application Should Have alternative drawable resources for different screen densities, Because Almost Every application launcher icon and HAS icon That Should look good on all screen densities. Likewise, if you include in your drawable bitmap Other application (Such as for menu icons or graphics in your application Other) You Should Provide alternative versions or Each One, for different densities.

Note: You Only Need to Provide for density-specific drawable bitmap files (. Png,. Jpg or. Gif) files and Nine-Path (.9. Png). If you use XML files to define shapes, colors, or Other drawable resources, You Should put one copy in the default directory drawable (drawable /).

To create alternative drawable bitmap for different densities, You Should follow the scaling ratio 3:4:6:8 Between the oven generalized densities. For example, if You Have a drawable bitmap that's 48x48 pixels for medium-density screen (the size for a launcher icon), all the different sizes Should Be:

    36x36 for low-density
    48x48 for medium-density
    72x72 for high-density
    96x96 extra for high-density

For more information about Designing icons, see the Icon Design Guidelines, Which includes information for Various size bitmap drawable, Such as launcher icons, menu icons, status bar icons, tab icons, and more. "

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
Auteur Android2EE
Ebooks to learn Android Programming.

No comments:

Post a Comment