Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a toggle button similar to the Twitter apps location toggle button?

What custom button should I use which could be slided right and left such as on turn on/off location button on android's twitter app as the picture below:

enter image description here

enter image description here

and also any link or guide to create such button ?

Thanks

like image 236
Faren Avatar asked Dec 09 '25 12:12

Faren


1 Answers

Use a simple ToggleButton in combination with a StateListDrawable set as its background.

A sample of the ToggleButton is to be found here.

Basically you create an image for the checked and unchecked state of the button. You set the appropriate images in the StateListDrawable and set that StateListDrawable as the ToggleButtos's background.

like image 189
Octavian A. Damiean Avatar answered Dec 11 '25 02:12

Octavian A. Damiean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!