/res/values/styles.xml
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="Style_One"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> </style> <style name="Style_One.Style_Two"> <item name="android:textColor">@android:color/holo_orange_light</item> </style> </resources>
MainActivity.java
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="iterator.ir.a040.MainActivity"> <TextView android:id="@+id/textView" style="@style/Style_One" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="55dp" android:gravity="center" android:text="Style One" android:textAppearance="@style/TextAppearance.AppCompat.Large" /> <TextView android:id="@+id/textView2" style="@style/Style_One.Style_Two" android:layout_alignEnd="@+id/textView" android:layout_alignRight="@+id/textView" android:layout_below="@+id/textView" android:layout_marginTop="40dp" android:gravity="center" android:text="Style Two" android:textAppearance="@style/TextAppearance.AppCompat.Large" /> </RelativeLayout>
References
https://github.com/mhdr/AndroidSamples/tree/master/040