
이게 제가 원하는 스타일이에요.
thumb는 그냥 이미지 drawable 넣으니까 바뀌는데, 뒤에 track은 on일 때 녹색, off일 때 회색으로 하고 싶어요
// bg_switch_track_on.xml
android:shape = "rectangle" >
< solid android:color = "#f00" />
< corners android:radius = "10dp" />
< size
android:width = "30dp"
android:height = "1dp" />
</ shape >
|
// bg_switch_track_off.xml
< solid android:color = "#ff0" />
< corners android:radius = "10dp" />
< size
android:width = "30dp"
android:height = "1dp" />
</ shape >
|
// bg_switch_track.xml
< item android:drawable = "@drawable/bg_switch_track_off" android:state_checked = "false" />
< item android:drawable = "@drawable/bg_switch_track_on" android:state_checked = "true" />
</ selector >
|
// activity_main.xml
< Switch
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:track = "@drawable/bg_switch_track" />
|
이렇게하면

이렇게 됩니다.
size가 안 먹히는데, 다른 방법이 있나요?
상관이 있을지는 모르겠지만, api는 22 전용이고, LG G4에서 개발하고 있어요.