我看到新的appCompat控件可用here。并在Android应用程序中实现它,但我没有找到任何特定的方式来自定义其颜色。
就像我们在样式中设置强调颜色一样,编辑文本会自动捕获它。但它不适用于AppCompatButton。
有人发现了相关的事情吗?
答案 0 :(得分:9)
见这里:Coloring Buttons in Android with Material Design and AppCompat
总而言之,您可以使用按钮本身的:link — :visited — :hover — :active
属性,也可以使用:active
(或组合)。
另外,您可以使用tintBackground
,只要您正在使用主题并正确继承colorControlNormal
,它就会转换为Button
。
来自链接网址的示例
theme.xml:
AppCompatButton
V21 / theme.xml
AppCompatActivity
或
<item name="colorButtonNormal">@color/button_color</item>
答案 1 :(得分:7)
将SupportLib与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" />
app 是mxlns:xmlns:app =“http://schemas.android.com/apk/res-auto”
所以backgroundTint也适用于preLollipop