How to change the track color of a SwitchCompat

后端 未结 10 1835
孤城傲影
孤城傲影 2020-11-29 18:01

I\'ve tried using the following link to change the color of a SwitchCompat:

How to change the color of a SwitchCompat

Notice the low constrast in my switch:<

10条回答
  •  北海茫月
    2020-11-29 18:19

    With the MaterialSwitch provided by the Material Components Library.

    • Use the materialThemeOverlay attribute to override the app color for the Switch.
      
      
    

    And in the layout:

    
    

    • Use the style attribute:
      
    

    with thumb_selector:

    
    
      
      
      
     
    

    and track_selector:

    
    
      
      
      
    
    

    And in the layout:

    
    

提交回复
热议问题