Rounded corners android image buttons

前端 未结 5 1091
孤独总比滥情好
孤独总比滥情好 2020-12-03 16:55

I am trying to round corners on an android ImageButton, the code looks like this;





        
5条回答
  •  Happy的楠姐
    2020-12-03 17:18

    You could use a selector made of shape drawables as background, for example :

    rounded_bg.xml (to be created in res/drawable-nodpi folder)

    
    
        
        
    
    
    

    Create another one, changing the color referenced in solid android:color="#ffffff" , for example to solid android:color="#ff0000" and name that file rounded_bg_selected.xml

    Create the selector (also in res/drawable-nodpi), name it selectable_button_bg.xml:

    
    
        
        
    
    

    Then reference it in your layout :

    
    

提交回复
热议问题