How can I create a toggle button similar to the Tw

2019-02-18 19:40发布

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

1条回答
神经病院院长
2楼-- · 2019-02-18 19:53

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.

查看更多
登录 后发表回答