问题描述:
在使用Api level 23及更低版本时,MaterialButton可能会出现以下问题:
解决方法:
可以通过以下两种方式解决该问题:
implementation 'com.google.android.material:material:1.3.0'
然后,在布局文件中将原生的MaterialButton替换为AppCompat库中的MaterialButton:
在上述示例中,button_background和button_icon分别是按钮的背景和图标资源。
注意:使用AppCompat库中的MaterialButton是更推荐的方法,因为它提供了与Material Design的一致性,并兼容更多的Android版本。