0

I need to change the color of both side in android switch button. I tried with android:textColorHighlight in my xml file but it seems not work. This is my code:

 <Switch
                android:id="@+id/sdrt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:textColorHighlight="@android:color/holo_green_dark"
                android:textOff="0"
                android:textOn="1" />

How could I change the background color of both selected and un-selected buttons in android switch?

IBunny
  • 309
  • 9
  • 20

2 Answers2

1

Based on the documentation, the textColorHighlight would not change the background color of your button. You can use style to set the background color of your button.

Please refer to How to set the text style of a button in selectors?

Community
  • 1
  • 1
dtheo
  • 123
  • 5
0

Looksl ike a bug. you have to call myTextView.setHighlightColor(Color.RED); for example in code...seems to not work when called from xml

j2emanue
  • 60,549
  • 65
  • 286
  • 456