在styles.xml中设置所有按钮样式 [英] Set all button style in styles.xml
本文介绍了在styles.xml中设置所有按钮样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使我的应用程序具有多种样式.
I want to make my app to have several styles.
样式更改按钮样式,文本视图颜色和布局背景颜色.
The style changes button style, textview color, and layout background color.
我在xml文件中有按钮样式.
I have my button style in xml files.
这是我的代码:style.xml(v21)
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?
请帮助.谢谢.
(抱歉英语不好;)
推荐答案
尝试更改此样式以仅更改应用程序中的按钮
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>
这篇关于在styles.xml中设置所有按钮样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文