How to set a gradient background to a Material Button?

前端 未结 4 1706
甜味超标
甜味超标 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:26

    LE: From my point of view I suggest you use Button or AppCompatButton.

    Try this:

    gradient.xml

    
    
        
    
    

    button.xml

    
    
    

    Result:

    With corner radius change gradient.xml to:

    
    
        
        
    
    

    Result:

提交回复
热议问题