<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/switch_thumb"
android:track="@drawable/switch_bg" />
switch_thumb.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/switch_thumb_disabled_holo_light" />
<item android:state_pressed="true" android:drawable="@drawable/switch_thumb_pressed_holo_light" />
<item android:state_checked="true" android:drawable="@drawable/switch_thumb_activated_holo_light" />
<item android:drawable="@drawable/switch_thumb_holo_light" />
</selector>
drawable-xxhdpi
switch_bg.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/switch_bg_disabled_holo_dark" />
<item android:state_focused="true" android:drawable="@drawable/switch_bg_focused_holo_dark" />
<item android:drawable="@drawable/switch_bg_holo_dark" />
</selector>
drawable-xxhdpi
텍스트 색상변경
<style name="SwitchTextAppearance" parent="@android:style/TextAppearance.Holo.Small">
<item name="android:textColor">@color/my_switch_color</item>
</style>
android:switchTextAppearance="@style/SwitchTextAppearance"
출처 : http://stackoverflow.com/questions/10118050/how-can-i-style-an-android-switch
http://stackoverflow.com/questions/12706874/how-to-change-textcolor-of-switch-in-android
'Dev_안드로이드 > 참고소스' 카테고리의 다른 글
안드로이드(Android) 배열 리소스 <string-array> (0) | 2016.08.05 |
---|---|
EditText에서 엔터키 눌렀을때 키보드 숨기기 (0) | 2016.08.04 |
ADB shell command (0) | 2016.07.27 |
UI 모음집 (0) | 2016.07.27 |
어플 개발시 저작권 걱정 없이 사용 가능한 무료 이미지 사이트 모음 (0) | 2016.07.27 |