在activity_main.xml的<TextView>控件中,通过 style="@style/TextSryle"引入定义好的样式,代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="math_parent"
android:layout_height="match_parent"
tool:context=".MainActivity">
<TextView
style="@style/TextStyle"
android:layout_centerInParent="true"
android:text="自定义样式”/>
</RelativeLayout>