问题
I want to make my app to have several styles.
The style changes button style, textview color, and layout background color.
I have my button style in xml files.
And this is my code: style.xml (v21)
<style name="ThemeIndigo" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:colorPrimary">@color/indigo</item>
<item name="android:colorPrimaryDark">@color/indigo</item>
<item name="android:navigationBarColor">@color/indigo_dark</item>
<item name="android:buttonStyle">@drawable/indigo_button</item>
<item name="android:background">@drawable/indigo_button</item>
</style>
This changes background color of all things on this layout.
How do I make my style to only change color of the buttons?
Please help. Thanks.
(Sorry for the bad english ;)
回答1:
Try this style to change for just buttons in the app
<style name="ThemeIndigo" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:buttonStyle">@style/MyButton</item>
</style>
<style name="MyButton" parent="android:Widget.Material.Button">
<item name="android:textSize">19sp</item>
<item name="android:layout_margin">0dip</item>
<item name="android:background">#ff0000</item>
</style>
来源:https://stackoverflow.com/questions/28963878/set-all-button-style-in-styles-xml