From the course: Android Development Essential Training: 1 Your First App

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Units of measurement in Android

Units of measurement in Android

- [Teacher] To support a variety of device screen sizes, it's recommended that you prefer the following units of measurement for your views and view groups. First, there's the density-independent pixels, also known as dp's or dips. Dips are flexible units that scale to have uniform dimensions on any screen. In this example, the size of the circle is specified in dips, so that it's displayed consistently across screens with varying density. Next, is the wrap_content constant. This tells your view to size itself to the dimensions required by its content. Nothing more. Here, we see an example of a TextView whose width and height is specified as wrap_content. So it only takes up the space needed to display the word, hello. And finally, we have the match_parent constant. This tells your view to become as big as its parent view group will allow. Here's that same TextView, except this time we've specified it's width…

Contents