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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.