Monday, June 6, 2011

Measurements in Android


We are used to designing interfaces in terms of pixels. But when developing for mobile devices we eventually have to deal with different displays. Resolution-independent measurements help to solve the problem of fitting content into different devices.
Android supports the following units:

  • px (pixels): Dots on the screen.
  • in (inches): Size as measured by a ruler.
  • mm (millimeters): Size as measured by a ruler.
  • pt (points): 1/72 of an inch.
  • dp (density-independent pixels): An abstract unit based on the density of the screen. On a display with 160 dots per inch, 1dp = 1px.
  • dip: Synonym for dp, used more often in Google examples.
  • sp (scale-independent pixels): Similar to dp but also scaled by the user’s font size preference.

For making your interface scalable to any current and future type of display, it is recommended you always use the sp unit for text sizes and the dip unit for everything else. Hello Android, 3rd edition

No comments:

Post a Comment