android - How to custom switch button? -
I would like to become as custom how to get it? Color and text change You can use the following code: <> Create .xml in xml designated colors res / values folder: In the drawable folder, to create an xml file my_btn_toggle.xml: And add your toggle button to define in the xml section: and list button:
pre & lt; org.jraf.android.backport.switchwidget.Switch android: id = "@ + id / th" Android: Layout_width = "Match_parent" Android: Layout_height = "Wrap_content" app: thumb = "@ drawable / apptheme_switch_inner_holo_light" app: Track = "@ drawable / apptheme_switch_track_holo_light" app: textOn = "@ string / switch_yes" app: textOff = "@ string / switch_no" Android: textcolor = "# 000000" / & gt;
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Resources & gt; & Lt; Color name = "red" & gt; # Ff0000 & lt; / Color & gt; & Lt; Color name = "green" & gt; # 00ff00 & lt; / Color & gt; & Lt; / Resources & gt;
Android: background = "@ drawable / my_btn_toggle
textOff
of the code
to change the Android color: switchTextAppearance = "@ style / switch"
Comments
Post a Comment