Chapter 13: Android App Layouts

Android layouts are the best tools in your toolkit for creating scalable applications. Because the Android platform was designed to support multiple device sizes and forms, it has a great set of layouts that you can utilize out of the box to support the widest possible selection of devices.

Android layout strategy

You should never define your Android user interfaces by setting absolute pixel positions to your components like you might do on other platforms. A user interface with an absolutely defined layout would look right on only one device. Instead of the absolute layout strategy Android user interfaces are built by defining how components relate to each other. In this sense designing layouts for Android is much closer to web design than to iOS design.

To make a layout scalable you must tell the operating system how the layout is to be scaled. Not all areas in the user interface should be resized. Android’s layouts let you define fixed areas and resizable areas. When used properly, these two types of areas will make your user interface scalable but maintain certain constraints for good results when scaling.

Fixed areas

A fixed area is a part of the user interface that cannot be resized. A typical example of this kind of area is a user interface icon. Icons are often a fixed size, and resizing them makes them look distorted.

Sometimes a fixed area is only fixed in one direction and resizable in the other. For example, a button bar often has a ...

Get Smashing Android UI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.