How to set custom button state background color?

后端 未结 2 716
谎友^
谎友^ 2020-12-11 17:40

I have a button which contains a drawable and text. I want the background of the button to be different than the normal one provided (preferably a plain color). This works f

2条回答
  •  北海茫月
    2020-12-11 18:11

    The xml you posted is suitable for a color state list, not a state list drawable. Try this instead:

    
        
            
        
        . . .
    
    

    Alternatively, put your existing file into res/color and use it as you would any other color. However, I don't remember if you can use a color state list directly as a background for a view.

提交回复
热议问题