O'Reilly logo

Mastering Android Studio 3 by Kyle Mew

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

Android styles

Graphical properties, such as background color, text size, and elevation, can all be set individually on any UI component. It often makes sense to group properties together into a style. Android stores such styles in the values directory as XML in the styles.xml file. An example of this is as follows:

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="TextStyle" parent="TextAppearance.AppCompat">         <item name="android:textColor">#8000</item>         <item name="android:textSize">48sp</item>     </style> </resources> 

Styles, such as this, can be applied to views and widgets simply and without having to specify each property, as follows:

<TextView     . . .      android:textAppearance="@style/TextStyle"     . . . /> 

It is quite possible ...

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