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 - Android Tutorial
From the course: Android Development Essential Training: 1 Your First App
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Define screens with activities4m 20s
-
(Locked)
Implement designs in XML layouts2m 47s
-
(Locked)
Introduction to Views and ViewGroups3m 19s
-
(Locked)
Display Views in a ViewGroup3m 28s
-
(Locked)
Units of measurement in Android4m 10s
-
(Locked)
Challenge: App template1m
-
(Locked)
Solution: App template3m 20s
-
(Locked)
-