Adding custom radio buttons in android

前端 未结 10 941
慢半拍i
慢半拍i 2020-11-22 11:43

I am trying to get radiobutton effect for regular buttons in android

I have a simple android radio button below

10条回答
  •  轮回少年
    2020-11-22 12:32

    Add a background drawable that references to an image, or a selector (like below), and make the button transparent:

    
    

    If you would like your radio buttons to have a different resource when checked, create a selector background drawable:

    res/drawable/yourbuttonbackground.xml

    
        
        
        
        
    
    

    In the selector above, we reference two drawables, a and b, here's how we create them:

    res/drawable/a.xml - Selected State

    
        
        
        
    
    

    res/drawable/b.xml - Regular State

    
        
        
        
    
    

    More on drawables here: http://developer.android.com/guide/topics/resources/drawable-resource.html

提交回复
热议问题