Use Android 4.0 styled toggle-button

safari picture safari · Mar 29, 2012 · Viewed 31.1k times · Source

What I'm trying to do


I'm trying to use in my Layout the Android 4.0 styled togglebutton. For this I selected the Theme = Theme.Holo.Light . When I take the togglebutton from there its that square with the green line, if the button is enabled.

But I'd like to use the togglebutton like they got in there config on top (take a look at the printscreen).

Question


How can I use thise togglebutton? Some Codesnippets or a quick tutorial would be great!

Best Regards

safari

Picture


screenshot of the togglebuttons

Answer

ankri.de picture ankri.de · Jul 30, 2012

New Edit: I now did a full backport of the Switch back to API Level 8 and put in on github: https://github.com/ankri/SwitchCompatLibrary


The old post with my custom implementation of the Switch:

I'm a bit late to the party but I had the same problem. I took the source code from the other post in this thred and made my own version of the switch.

You can find the source code and documentation on my website

This is what it looks like:

SwitchButtonDemo screenshot

edit: Updated link and picture