我怎样才能创建一个类似于Twitter的应用程序的位置切换​​按钮切换按钮? [英] How can I create a toggle button similar to the Twitter apps location toggle button?

查看:126
本文介绍了我怎样才能创建一个类似于Twitter的应用程序的位置切换​​按钮切换按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用什么自定义按钮,可滑动左右如开/关按钮的位置上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 的背景。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆