How to set custom button state background color?

后端 未结 2 715
谎友^
谎友^ 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 17:45

    EXAMPLE:

    XML file saved at res/color/button_text.xml:
    
        
        
             
             
             
        
        This layout XML will apply the color list to a View:
    
        

    @color/button_text

    res/color/button_text.xml

    This is the example provided by Google in the ColorStateList Resource: https://developer.android.com/guide/topics/resources/color-list-resource.html

    I think colorStateList must be used to change color of textView of a widget.

提交回复
热议问题