您可以为每种小部件类型所需的不同颜色或可绘制对象定义不同的样式,并参考各种主题中的样式。例如:
<!-- themes -->
<style name="MyTheme" parent="android:style/Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/something</item>
<item name="android:buttonStyle">@style/MyButton</item>
</style>
<style name="MyTheme.Red">
<item name="android:buttonStyle">@style/MyButton.Red</item>
</style>
<style name="MyTheme.Blue">
<item name="android:buttonStyle">@style/MyButton.Blue</item>
</style>
<!-- styles -->
<style name="MyButton" parent="android:style/Widget.Button">
<item name="android:background">@drawable/btn_mydefault</item>
</style>
<style name="MyButton.Red">
<item name="android:background">@drawable/btn_red</item>
</style>
<style name="MyButton.Blue">
<item name="android:background">@drawable/btn_blue</item>
</style>