Applying local styles and global themes

Themes are Android's mechanism for applying a consistent style to an app or activity. A style specifies the visual properties of the elements that make up your user interface, such as color, height, padding, and font size.

How to do it...

  1. We can create styles for views using the various attributes:
    <TextView
      style="@android:style/TextAppearance.Medium"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:textColor="#7F3300"
      android:typeface="monospace"
      android:gravity="center"
      android:text="Inline Styles" />
  2. These styles can be extracted into a separate file so that they can be reused across views, as with string resources. In this case, we inherit from the Android style TextAppearance.Medium ...

Get Xamarin Mobile Development for Android Cookbook 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.