Styles and Themes

Android provides several ways to alter the style of views in your application. We'll first cover using markup tags in strings and then how to use spannables to change specific visual attributes of text. But what if you want to control how things look using a common specification for several views or across an entire activity or application? We'll discuss Android styles and themes to show you how.

Using Styles

Sometimes, you want to highlight or style a portion of the View's content. You can do this statically or dynamically. Statically, you can apply markup directly to the strings in your string resources, as shown here:

<string name="styledText"><i>Static</i> style in a <b>TextView</b>.</string>

You can then reference it ...

Get Pro Android 4 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.