Set com.google.android.material.chip.Chip selected color

后端 未结 6 1373
你的背包
你的背包 2021-02-01 02:42

How do I set the selected com.google.android.material.chip.Chip color? I don\'t want it to be the default gray. This is a single selection chip group.

Original

6条回答
  •  深忆病人
    2021-02-01 03:11

    Using a ColorStateList is a proper way. The only thing I want to add is using custom defined style much more clear to read especially if you want to customise a bunch of properties.

    Among other things, one common style applied to all views allows you to make changes in one place that apply immediately to all views

    styles.xml

    
    

    text_color_chip_state_list.xml

    
        
        
    
    

    background_color_chip_state_list.xml

    
    
        
        
    
    

    After that all you need is apply your custom style for all the Chip views like this.

    
    

提交回复
热议问题