Android - Screen Resolution and Screen Density

In accordance with the control resources (images) in Android 1.6, we need to save images with different resolutions in the Drawable-Hdpi, Drawable-Mdpi, Drawable-Lpi folder.

And according to this page: http://developer.android.com/guide/practices/screens_support.html ,

In the section with a low density - three resolutions are used: 240 * 320, 240x400, 240x432 for a small screen, a regular screen, especially a large screen.

the same for the medium-density section - three resolutions are used: 320x480, 480x800, 480x854 for a small screen, a regular screen, especially a large screen.

the same way for high density ........

but I'm confused here:

(1) How do I know if a small, regular, or large screen is being used, I mean, is there a way to find out?

(2) How do I know which type of density I am using?

(3) And in Drawable-Hdpi, Drawable-Mdpi, Drawable-ldpi folder, a resolution image that we should save especially?

Share your knowledge.

+4
source share
3 answers

There are special Android API calls that can tell you during operation what density and (small / large / normal) screen size the phone has. However, as a developer, we do not need to worry about individual phones at all. All we need to do is have ldpi / mdpi / hdpi assets and small / normal / large layouts in apk. Android internally handles everything.

Remember to get a deep understanding of how Android determines which assets to use and smooth here .

+7
source

Why do you want to know the actual density? This is an Android business. But I'm sure there is a way to get this information.

For development, I put everything in the hdpi folder. I could also put everything in a shared graphics folder.

At a time when u publish u can decide whether you want to provide already scaled resources for ldpi and mdpi. However, this is not necessary.

Update: Get actual density using this class and best practices.

Update 2: I found a 25-minute video from Motorola that discussed all these issues: Working with multiple screens

+3
source

1) Change the contents of the layout in different folders, i.e. layout, small, layout large, etc. Now test it in another emulator with different screen resolutions.

2) To determine the density of use of the device
Log.d("Density", "" + (getResources().getDisplayMetrics().density));

+1
source

All Articles