我在android x上使用了新的 Material 组件com.google.android.material:material,但无法为按钮设置自定义背景。

我知道我可以使用app:backgroundTint更改颜色

但是默认背景有一些我想摆脱的填充,以及使用android:background设置自己的背景的旧方法,但是这种方法不再起作用。

我查看了docs,但找不到任何有关此更改的信息。

最佳答案

The documentation for the MaterialButton class说:



但是,the GitHub readme说:



这仅提及左/右插图,但自述文件的the Attributes section显示支持所有四个插图:

android - 无法使用android :background with button from the new material components-LMLPHP

因此,您可以将以下属性添加到<MaterialButton>标记中:

android:insetTop="0dp"
android:insetBottom="0dp"

关于android - 无法使用android :background with button from the new material components,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52673053/

10-11 22:39
查看更多