无法将colorButtonNormal值更改为所有按钮 [英] Cant change colorButtonNormal value to all buttons
本文介绍了无法将colorButtonNormal值更改为所有按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用样式中的colorButtonNormal
使应用程序中的所有按钮具有默认颜色.
I am trying to make all buttons in my app have default color using colorButtonNormal
in my style.
它在API 21及更高版本上运行良好,但在API 21下,它仅更改了某些按钮的背景,我不知道出了什么问题.
It works nice on API 21 and above but under API 21 it only changes the background of some buttons and i dont know what is going wrong.
styles.xml
styles.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="colorPrimary">@color/btn_login</item>
<item name="colorPrimaryDark">@color/bg_login</item>
<item name="colorAccent">@color/btn_login</item>
<item name="colorButtonNormal">@color/btn_login</item>
</style>
</resources>
v21/styles.xml
v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="android:alertDialogTheme">@style/AlertDialogCustom</item>
<item name="android:colorButtonNormal">@color/btn_login</item>
<item name="colorPrimary">@color/btn_login</item>
<item name="colorPrimaryDark">@color/bg_login</item>
<item name="colorAccent">@color/btn_login</item>
</style>
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:colorPrimary">@color/btn_login</item>
<item name="android:colorAccent">@color/btn_login</item>
<item name="colorAccent">@color/btn_login</item>
<item name="colorPrimary">@color/btn_login</item>
<item name="colorPrimaryDark">@color/bg_login</item>
</style>
<style name="Preference" parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">@color/black</item>
<item name="android:colorPrimary">@color/btn_login</item>
<item name="android:colorAccent">@color/btn_login</item>
<item name="android:editTextColor">@color/black</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:alertDialogTheme">@style/AlertDialogCustom</item>
<item name="colorAccent">@color/btn_login</item>
</style>
<style name="EditTextThemeCustom" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:editTextColor">@color/black</item>
<item name="android:textColor">@color/black</item>
<item name="colorAccent">@color/btn_login</item>
</style>
</resources>
结果:
和
有什么建议吗?
推荐答案
添加到您的styles.xml
<style name="ColoredButton" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/btn_login</item>
</style>
然后使用
android:theme="@style/ColoredButton"
作为按钮的属性之一
这篇关于无法将colorButtonNormal值更改为所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文