How to set a gradient background to a Material Button?

前端 未结 4 1695
甜味超标
甜味超标 2021-01-17 11:57

I\'m currently using this code but the background is not changing.It is still showing accent-color as background.



        
4条回答
  •  别那么骄傲
    2021-01-17 12:17

    To use a custom drawable background with the MaterialButton you can use the android:background attribute:

    
    

    NOTE: It requires at least the version 1.2.0-alpha06

    Currently it is very important to add app:backgroundTint="@null" to avoid that the custom background doesn't get tinted by default with the backgroundTint color.

    With lower versions of the Material Components Library you have to use an AppCompatButton.

提交回复
热议问题