O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required