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

那年仲夏 提交于 2019-12-01 05:38:47

问题


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:

and also any link or guide to create such button ?

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/4978689/how-can-i-create-a-toggle-button-similar-to-the-twitter-apps-location-toggle-but

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!