Provide Optimized Resources for Different Screens

When using Drawable resources that cannot be dynamically scaled well, you should create and include image assets optimized for each pixel density category (low, medium, and high). Application icons are an excellent example of a resource that should be optimized for different pixel densities.

Using the resource framework described earlier in the chapter (and in Chapter 3), you can create annotated Drawable directories to store image assets for each supported density, as shown in the following list:

V res/drawable-ldpi

V res/drawable-mdpi

V res/drawable-hdpi

By creating assets optimized for the pixel density of the host platform you ensure that your UI will be crisp and clear and devoid of artifacts like aliasing and lost pixels — typical side effects of scaling.

Similarly, you should consider creating alternative layout definitions for different screen sizes. A layout optimized for a typical smartphone screen may crop important information on a small device, or appear too sparse when displayed on a large device such as a tablet.

Use the resource framework to annotate the layout resource folder to create specialized layouts for small, normal, and large screens, as shown in the following list:

V res/layout-small

V res/layout-normal

V res/layout-large

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment