样式定义Android界面样式

res/values/style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="style1">
        <item name="android:textSize">18sp</item>
        <item name="android:textColor">#EC9273</item>
    </style>
    <style name="style2">
        <item name="android:textSize">14sp</item>
        <item name="android:textColor">#FF7F7C</item>
        <item name="android:fromAlpha">0.0</item>
        <item name="android:toAlpha">0.0</item>
    </style>
</resources>

res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView 
	style="@style/style1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
    <TextView
    style="@style/style2"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

运行结果
image

原文地址:https://www.cnblogs.com/AlexCheng/p/2120051.html