From the course: Android Development Essential Training: The User Interface with Kotlin

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Units of measurement in Android

Units of measurement in Android - Android Tutorial

From the course: Android Development Essential Training: The User Interface with Kotlin

Start my 1-month free trial

Units of measurement in Android

- [Instructor] The Android framework supports a specific set of units of measurement to control the placement and size of visual objects. These are known as dimensions and dimension values. The first and most important unit of measurement to discuss is called device independent pixels, abbreviated as dp. You typically use dps to set the positioning and sizing of containers and widgets. Device independent pixels are calculated based on a theoretical screen that has 160 pixels per square inch or ppi. If you say an object is 100 dps wide and then you run that app on a screen with 160 pixels per square inch, it'll be exactly 100 pixels. But if you run that same app on a device whose screen has a greater pixel density, let's say one that has 320 pixels per square inch, then the device independent pixel measurement will be adjusted automatically for you. The ratio of device independent pixels to physical pixels changes with the screen density. There's another similar unit of measurement…

Contents