android中样式使用style.xml

1、样式的定义:

    <style name="jiangnanstyle" >
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#ff0000</item>
        <item name="android:textSize">30sp</item>
    </style>
    <style name="pangzhi" parent="jiangnanstyle">
        <item name="android:textColor">#00ff00</item>
    </style>
    <style name="pangzhi.lizhi">
        <item name="android:textSize">50sp</item>
    </style>

2、样式的使用:

    <TextView
        android:text="@string/hello_world"
        style="@style/jiangnanstyle"/>
    <TextView
        android:text="@string/hello_world"
        style="@style/pangzhi"/>
    <TextView
        android:text="@string/hello_world"
        style="@style/pangzhi.lizhi"/>

猜你喜欢

转载自blog.csdn.net/a987687115/article/details/50392612