Can't use android:background with button from the new material components

后端 未结 4 1783
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-18 20:52

I\'m using the new material components com.google.android.material:material with android x but I can\'t set a custom background to the button.

I know that I

4条回答
  •  不思量自难忘°
    2021-02-18 21:25

    In the Material Components Library, the MaterialButton has a default style with insetBottom and insetTop with a value of 6dp.

    You can change it using:

      
    

    If you want to change the background color you can use the app:backgroundTint attribute or you can override some theme attributes from a default style then you can use new materialThemeOverlay attribute.

    In your case you can do something like:

    
    
    
    

    Finally starting with the version 1.2.0-alpha06 you can use the android:background attribute in the MaterialButton.

    
    

提交回复
热议问题