我怎样才能创建一个类似于Twitter的应用程序的位置切换按钮切换按钮? [英] How can I create a toggle button similar to the Twitter apps location toggle button?
问题描述
我应该使用什么自定义按钮,可滑动左右如开/关按钮的位置上Android的Twitter的应用程序,如下图:
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 ?
感谢
推荐答案
使用一个简单的切换按钮与一个 StateListDrawable 设置为背景
Use a simple ToggleButton in combination with a StateListDrawable set as its background.
的样本切换按钮
是可以找到的这里。
基本上你创建按钮选中和未选中状态的图像。您可以在 StateListDrawable
,并设置 StateListDrawable
为 ToggleButtos $设置相应的图像C $ C>的背景。
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.
这篇关于我怎样才能创建一个类似于Twitter的应用程序的位置切换按钮切换按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!