implementation 'com.google.android.material:material:1.4.0'
属性 | 描述 |
---|---|
app:backgroundTint | 背景着色 |
app:backgroundTintMode | 着色模式 |
app:strokeColor | 描边颜色 |
app:strokeWidth | 描边宽度 |
app:cornerRadius | 圆角大小 |
app:rippleColor | 按压水波纹颜色 |
app:icon | 图标icon |
app:iconSize | 图标大小 |
app:iconGravity | 图标摆放位置 |
app:iconTint | 图标着色 |
app:iconTintMode | 图标着色模式 |
app:iconPadding | 图标和文本之间的间距 |
注意事项
设置按钮背景 使用app:backgroundTint
细心的老哥肯定发现Button 普通按钮 与MaterialButton 效果一样,这是因为在AndroidManifest.xml中application标签设置了theme属性
为什么使用MaterialButton ?
因为它可以帮助我们减少drawable文件
上布局文件源代码