2-9. Implementing Situation-Specific Layouts
Problem
Your application must be universal, running on different screen sizes and orientations. You need to provide different layout resources for each of these instances.
Solution
(API Level 4)
Build multiple layout files, and use resource qualifiers to let Android pick what’s appropriate. We will look at using resources to create layouts specific for different screen orientations and sizes. We will also explore using layout aliases to reduce duplication in cases where multiple configurations share the same layout.
How It Works
Orientation-Specific
In order to create different resources for an activity to use in portrait vs. landscape orientations, use the following qualifiers:
- resource-land ...
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