[英]How to customize AppCompatButton color
我在这里看到了新的appCompat控件。 并在Android应用程序中实现它,但我没有找到任何特定的方式来自定义其颜色。
就像我们在样式中设置强调色一样,编辑文本会自动捕获它。 但它在AppCompatButton的情况下不起作用。
有没有人发现这件事?
请参阅此处: 带有Material Design和AppCompat的Android中的着色按钮
总而言之,您可以在按钮本身上使用tintBackground
属性,也可以使用colorControlNormal
(或组合)。
此外,你可以使用Button
,它会转换为:一个AppCompatButton
为您所使用的主题,继承,只要AppCompatActivity
正确。
链接的URL中的示例
theme.xml:
<item name="colorButtonNormal">@color/button_color</item>
V21 / theme.xml
<item name="android:colorButtonNormal">@color/button_color</item>
要么
<Button
android:id="@+id/add_remove_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/bg_remove_btn_default"
android:textColor="@android:color/white"
tools:text="Remove" />
像这样使用SupportCompib和AppCompatButton:
<android.support.v7.widget.AppCompatButton
android:id="@+id/add_remove_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="@color/bg_remove_btn_default"
android:textColor="@android:color/white"
tools:text="Remove" />
应用程序是一个mxlns:xmlns:app =“http://schemas.android.com/apk/res-auto”
所以backgroundTint也适用于preLollipop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.