自定义(圆形)切换按钮
我正在尝试在 Android 中构建一个自定义切换按钮,我希望它看起来像单选按钮,但功能充当切换按钮。有人可以帮我解决这个问题吗?任何接近答案的线索提示都值得赞赏。
I am trying to build a custom toggle button in Android, I want it to look like radio button but function as toggle button. Can some one help me with this? any clue hints close to answer is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要通过一些自定义 xml 快速概述来覆盖切换按钮的外观
:
在布局 xml 中
android:background="@drawable/round_toggle" />
在 round_toggle.xml 中添加具有尽可能多状态的选择器(最多 6 个 + 默认值)
http://www.anddev.org/act_custom_togglebuttons-t10620.html
You need to override the look of the toggle button via some custom xml
quick overview:
in your layout xml
android:background="@drawable/round_toggle" />
add selectors with as many states (up to 6 + default) in round_toggle.xml
full details in http://www.anddev.org/act_custom_togglebuttons-t10620.html
为什么不使用 RadioButton 视图和 RadioGroup 布局?
Why not use the RadioButton view and RadioGroup layout?
您可以尝试重新设置复选框的外观。以下链接是有关执行此操作的教程:
链接
You could try re-skinning a checkbox. The following link is a tutorial on doing so:
link