Android: Setting up custom gradient for button

后端 未结 3 1805
遇见更好的自我
遇见更好的自我 2021-01-25 23:52

    
          


        
3条回答
  •  故里飘歌
    2021-01-26 00:28

    You should either define the gradient in XML or use an image (which will include the rounded corners). You can't easily mix both an XML shape with an image (at least, as you are a beginner, I would recommend to go with simple stuff first).

    For instance:

    
    
        
        
    
    

    Then you can define your button's background using the android:background="@drawable/bg_custom_button"

    You should learn about nine-patches, they allow you to define strechable images for your backgrounds and will save you when the design is not feasible with XML.

提交回复
热议问题