Sunday, January 8, 2012

Using Built-In Android Styles

I've seen a number of great articles on how to define your own custom styles in Android applications, but I wanted to know how to use built-in ones. Turns out it's easy!


To make a TextView use the built-in style android.R.style.TextAppearance_Large_Inverse, just define it like so:


    <TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Large.Inverse"
android:text="Text" >
</TextView>


The key is to replace all the underscores with periods in the style name.