3

As per managing resources(images) in > Android 1.6 version, we need to keep different-resolutions image in Drawable-Hdpi, Drawable-Mdpi, Drawable-Lpi folder particularly.

And as per this page: http://developer.android.com/guide/practices/screens_support.html ,

In Low density section - there are three resolutions used: 240*320 , 240x400 , 240x432 for the Small screen, Normal Screen, Large Screen particularly.

same way for Medium density section - there are three resolutions used: 320x480 , 480x800 , 480x854 for the Small screen, Normal Screen, Large Screen particularly.

and same way for High density ........

but i am confused here:

(1) How do i come to know that whether small, Normal or Large screen is used, i mean is there any way to know ?

(2) How do i come to know which type of density i am using ?

(3) And in Drawable-Hdpi, Drawable-Mdpi, Drawable-ldpi folder, which resolution's image we should keep particularly?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295

3 Answers3

7

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

Dont forget to get an indepth understanding of how Android determines which assets to use and aliasing here.

omermuhammed
  • 7,365
  • 4
  • 27
  • 40
  • I put mine in Xhpdi but they do not always scale, some do, some dont. So I think putting in to different folders is preferred, especially if you are making a big app to maximize performance and user experience. no? – Green_qaue Jan 28 '14 at 02:38
  • Agreed, also don't forget to use 9 patch images when possible. They help quite a bit. – omermuhammed Jan 28 '14 at 17:52
3

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

For development I put everything in the hdpi-folder. I also could put everything in a general Drawable Folder.

At the time u publish u can decide if u want to provide already downscaled resources for ldpi and mdpi. However, thats not necessary.

Update: Retrieve actual density with this class and best practices

Update 2: I found a 25 min video from Motorola discussing all those issues: Working with multiple screens

OneWorld
  • 17,512
  • 21
  • 86
  • 136
  • if you put everything hdpi-folder, is it ok for every resolutions? will images get stretched/cropped ? – Paresh Mayani Sep 28 '10 at 05:26
  • Yes its ok. They will be up- or downscaled. U also can set a certain stretch/crop behavior if u want to with scale_type in imageViews. You also should always use dp- and sp-Dimensions, then you are all fine. You also can test different screensizes in the SDK in the preview and as VM. – OneWorld Sep 28 '10 at 07:09
  • thanx for such information and ya i am already being using scale_type for imageview and also setting the dimensions using dip(dp) or sp – Paresh Mayani Sep 29 '10 at 05:44
  • If you retrieve resources dynamically, say from a web server, you may want to request the best resource for the current resolution. – ThomasW Feb 10 '11 at 09:43
1

1) Change the content of the layout in different folders i.e layout-small, layout-large, etc Now test it in Different emulator with different screen resolution.

2) For Finding out density of the Device use
Log.d("Density", "" + (getResources().getDisplayMetrics().density));

Flexo
  • 87,323
  • 22
  • 191
  • 272
Hardik4560
  • 3,202
  • 1
  • 20
  • 31