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

Which user button should I use, which can be moved left and right, for example, by turning on / off the location button in the Android twitter app, as shown below:

enter image description here

enter image description here

as well as any link or guide to create such a button?

thanks

+3
source share
1 answer

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

A sample ToggleButton can be found here .

Basically you create an image for the marked and unchecked state of the button. You set the appropriate images to StateListDrawable and set that StateListDrawable as the background of ToggleButtos .

+3
source

Source: https://habr.com/ru/post/1396806/


All Articles