-1

A dumb question, in Android, we use dp because we care more about physical size, then was it not possible to use something existing like cm,mm,.....? I'm not understanding why we should use dp instead of existing physical measurements unit

Noor
  • 19,638
  • 38
  • 136
  • 254
  • 2
    Relative: http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android – nKn Apr 25 '14 at 22:10
  • 1
    I'm not understanding why are downvoting this question – Noor Apr 25 '14 at 22:13
  • A totally legit question. It's unfairly closed. `dp` is actually not a strictly physical size unit. It depends on density assigned to device which not always corresponds to exact density. Also usually vertical and horizontal densities differ slightly. – defhlt Mar 09 '15 at 23:35

3 Answers3

2

we use dp because we care more about physical size, then was it not possible to use something existing like cm,mm,.....?

You are welcome to use mm, as that is a valid dimension unit.

I'm not understanding why we should use dp instead of existing physical measurements unit

You are welcome to use mm if you want. I cannot think of any place that forces you to use dp, though there may be some. Others are welcome to use dp/dip, for any number of reasons (e.g., it matches the CSS px unit).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I agree and you are right, I just asked this question after some searching about why the reason of using dp when we already have measurement units that are density independant, nothing more – Noor Apr 25 '14 at 22:35
1

You choose what you prefer: px, mm or dp. 1 dp is equal to 1 pixel on the screen of the first Android devices which had a display with a density of about 160 dpi (dots per inch).

BladeCoder
  • 12,779
  • 3
  • 59
  • 51
  • for other displays **dp = px * density scale factor**: 0.75 for ldpi, `1.0 for mdpi`, 1.5 for hdpi, 2.0 for xhdpi, 3.0 for xxhdpi, 4.0 for xxxhdpi. – Phantômaxx Apr 26 '14 at 09:19
0

That's just how Android was designed. They chose to use units that relate specifically to pixel density. It may also be that different locales use different units of measurement (inches in US, cm in most other places, etc), but if they define their own then it's the same everywhere.

Karakuri
  • 38,365
  • 12
  • 84
  • 104