Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications
by James Talbot, Justin McLean, Jorge Hernandez
Using Resource Dimensions
There should be a better way in Android to have slightly smaller buttons on a smaller screen than by creating a new layout—and there is. With dimension values, a single layout can scale to a wide variety of sizes and densities. The other option is to create a new layout file for every configuration, which can become a maintenance nightmare very quickly because of duplicated code. Instead, having a single layout file that loads the appropriate dimension information at run time will make your life as a developer quite a bit simpler.
Here’s how to create a layout for a small screen by using the small resource qualifier.
1. Delete the layout-small directory and the timer_layout file inside it.
2. Create a new values-small ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access