1

This sounds stupid , but I have confusion. I have defined a layout which have a stripe of images . Strip height is set as some x dp. But I can see difference in height , in difference phones (in samsung note2 it looks bigger than nexus 4). Can someone explain or provide some useful links ?

Thanks in advance.

user1875798
  • 263
  • 3
  • 6
  • 16

3 Answers3

3

FYI, DP stands for Density independent pixel.

And Here is definition of Screen density:

Screen density

The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen.

Reference: http://developer.android.com/guide/practices/screens_support.html

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • I have read there ,according to it x dp should look of same size independent of screen density and size. but what I have observed is different . I can see size difference in difference screen size phones. – user1875798 Apr 08 '13 at 12:43
  • @user1875798 you have observed it right, but button/image with 1 dp will be looking different because 1 dp measurement will be done based on the density of the particular device. If its ldpi then your 1 dp button will look small and if its hdpi screen then it will superb. – Paresh Mayani Apr 08 '13 at 12:53
  • 1dp can have different number of pixels based on device density means a device 1dp can have x pixels and another can have y pixels but size should appear same that is what I have understood from http://developer.android.com/guide/practices/screens_support.html. so ideally device is ldpi or hdpi should not matter , correct me if I am wrong. – user1875798 Apr 08 '13 at 13:02
  • @user1875798 At one side you are saying *different pixels in different devices* and at another side you are saying it should be same, how strange !! – Paresh Mayani Apr 08 '13 at 13:03
  • what I know is 1 dp is equivalent to 1 pixel size in a 160 dpi device. After that If dpi differs you can cal pixels in dp but size remains constant. – user1875798 Apr 08 '13 at 13:05
0

The mdpi, hdpi, xhdpi, ... suffixes stands for generalized densities.

That means that 2 xhdpi phones might have slightly different real densities.

For example, Galaxy Nexus and Galaxy SIII are both noted as xhdpi, but Galaxy Nexus has a 316ppi screen, whereas Galaxy SIII screen is a 306ppi

source: Wikipedia

nicopico
  • 3,606
  • 1
  • 28
  • 30
  • I agree that both can have different density but If I am defining size in dp in that case density should not matter. Correct me If I am wrong. – user1875798 Apr 08 '13 at 13:09