背景知识
Material组件
默认的<Botton>其实为MaterialButton,
MaterialButton继承自AppCompatButton,在原来Button的基础上做了一些拓展。
MaterialButton自动忽略<backgroud>,使用下面的属性作为默认背景样式
Theme.MaterialComponents.DayNight.DarkActionBar
查看路径如下:
修改方式:
1.全局修改
自定义xml样式:修改上述代码为
Theme.MaterialComponents.DayNight.NoActionBar.Bridge
但使用该方式会导致全局样式改变
2.更改属性
仅改变颜色
可以通过android:backgroundTint属性设置背景颜色
通过android:background设置背景
需要将backgroundTind属性设置为@empty
android:background="@drawable/custom"
android:backgroundTint="@empty"
3.更改控件
用<android.weiget.Button>代替<Button>