Units Of Measurement

Description

When specifying the size of an element on an Android UI, you should know the following units of measurement:

dp

dp is Density-independent pixel.
1 dp is equivalent to one pixel on a 160 dpi screen.
This is the recommended unit of measurement when specifying the dimension of views. The 160 dpi screen is the baseline density assumed by Android. You can specify either "dp" or "dip" when referring to a density-independent pixel.

sp

sp is Scale-independent pixel. This is similar to dp and is recommended for specifying font sizes.

pt

pt - Point.
A point is defined to be 1/72 of an inch, based on the physical screen size.

px

px - Pixel.
Corresponds to actual pixels on the screen. Using this unit is not recommended, as your UI may not render correctly on devices with a different screen resolution.





















Home »
  Android »
    Android UI »




UI Basics
Action Bar
Animation
Button
Canvas
CheckBox
Clock Date Picker
Dialog
EditText
Event
Fragment
Gesture
GridView
ImageView
Layout
ListView
Map
Menu
Model
OpenGL
ProgressBar
RadioButton
Spinner
Tab
TextView
Thread
Toast
Video
View
WebView