2012-06-29 46 views
2

可能重复:
Android: How to create slide (on/off) button如何实现滑动按钮?

我要创造我的Android应用程序的滑动按钮,使得它看起来像下面这样:

enter image description here

哪有我这样做?

+2

更新:[** Switch widget **](http://developer.android.com/reference/android/widget/Switch.html)也在那里。 –

+0

请参阅下面的链接以制作自定义切换按钮。 [链接1](http://stackoverflow.com/questions/9938315/toggle-button-in-iphone-style)[链接2](http://www.mokasocial.com/2011/07/sexily-styled- toggle-buttons-for-android /) –

回答

5

使用ToggleButton创建此滑动按钮

请参见本教程中的Android创建自定义切换按钮

Sexily Styled Toggle Buttons for Androidarchive.org mirror

编辑:,如果您使用的是Android API等级14以上那么你也可以使用Switch Widget来创建滑动按钮,看这个例子:

Creating a Switch

+0

如何使用['Switch Widget'](http://developer.android.com/reference/android/widget/Switch.html)? –

+1

在Android API Level 14中添加了Switch Widget,我没有得到任何工作示例。 –

+1

是的..我正在4.0.3上工作。感谢paresh和imaran的帮助..它的工作原理 –