样式的设置:
/StyleRes/res/values/my_style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="style1">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#00d</item>
</style>
<style name="style2">
<item name="android:background">#ee6</item>
<item name="android:padding">8dp</item>
</style>
</resources>
样式的引用:
/StyleRes/res/layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="樣式1"
style="@style/style1" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="樣式2"
style="@style/style2" />
</LinearLayout>
效果图: