Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know which phone support which layout(hdpi , mdpi and xhpi)?

I'm a little confused about how to determine which phones support what layout types. I've done some research but haven't found a satisfying answer.

For example, I've found the below guide:

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

However, I still have some concerns:

  1. Samsung grand (480*800) and HTC wild fire S (320*480) both support MDPI. These screens have very different resolutions, yet have the same layout type?

  2. Galaxy note 2 (1280*720) support HDPI. If HD (720p) is only HDPI, when what device/resolution supports XHDPI?

  3. I've already asked a related question here: How to set layout on 7" two different tablet?.

  4. My most important question, however, is this: How do I know which devices or screen resolutions support each layout type?

like image 547
duggu Avatar asked Jun 03 '13 04:06

duggu


People also ask

What is Hdpi and Mdpi in Android?

For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be: 36x36 (0.75x) for low-density (ldpi) 48x48 (1.0x baseline) for medium-density (mdpi) 72x72 (1.5x) for high-density (hdpi) 96x96 (2.0x) for extra-high-density (xhdpi)

What is Hdpi screen?

Hdpi is a 1.5:1, and can be thought of as a HD (high-definition) display. And xhdpi is 2:1, much like Apple retina displays. . The normal mdpi is based on a 160 dpi screen, which again is the same as a single pixel unit in your graphics software.

What is Mdpi Hdpi Xhdpi?

DPI is dots/inch. Low density - ldpi - (100-130 dpi) Medium density - mdpi - (120-180 dpi) High density - hdpi - (180-280 dpi) Extra High density - xhdpi - (280-360 dpi)

What is Mdpi image?

mdpi is the reference density -- that is, 1 px on an mdpi display is equal to 1 dip. The ratio for asset scaling is: ldpi | mdpi | hdpi | xhdpi | xxhdpi | xxxhdpi 0.75 | 1 | 1.5 | 2 | 3 | 4.


1 Answers

Android treats mdpi (160 pixels/inch) as the base density. So for mdpi devices, 1 dp = 1 pixel. At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi).

AutoMatic Scaling by Android itself:

Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi.

Using different versions of graphics :

If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. These graphics should be of the same size that Android would scale an mdpi resource.

Note : the pixels/inch that was stored in the image file has nothing to do with this. It's all based on where you put the graphics files in the resources directory for your project. Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules.

As the ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.

the ratio in pixels between them is:

ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3

so lets take an image with about the size of 100X100:

for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300

this way, for screens with the same size but different DPI, all the images seem the same size on screen.

like image 148
Ritesh Gune Avatar answered Sep 24 '22 14:09

Ritesh Gune