Using 9-Patch Images

If you enlist a professional designer to craft your UI, what they give you may not be achievable with XML drawables. It may still be possible to reuse the rendered asset in multiple places, though. For stretchable UI elements like button backgrounds, Android provides a tool called the 9-patch.

Your next task is to fix up the two TextViews at the top of the screen. You will keep your button layout the same, but use stretchable drawables for their backgrounds. Both of them are much narrower than your TextViews, so that they do not take up much space. The first one, window.png, is a stretchable background designed to give your TextView a tasteful fade, along with some border space on the edges.

Figure 25.5  Channel display ...

Get Android Programming: The Big Nerd Ranch Guide 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.