Adding custom radio buttons in android

前端 未结 10 795
慢半拍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:19

    I have updated accepted answer and removed unnecessary things.

    I have created XML for following image.

    Your XML code for RadioButton will be:

    
    
    
            
    
            
    
    
    

    radio_flat_selector.xml for background selector:

    
    
        
        
    
    

    radio_flat_selected.xml for selected button:

    
    
        
        
        
    
    

    radio_flat_regular.xml for regular selector:

    
    
        
        
        
    
    

    All the above 3 file code will be in drawable/ folder.

    Now we also need Text Color Selector to change color of text accordingly.

    radio_flat_text_selector.xml for text color selector

    (Use color/ folder for this file.)

    
    
        
        
    
    

    Note: I refereed many answers for this type of solution but didn't found good solution so I make it.

    Hope it will be helpful to you.

    Thanks.

提交回复
热议问题