Android-ToggleButton和Switch

ToggleButton与Switch都是开关按钮,ToggleButton出现在比较早的版本中,Switch是最近几个版本才出现的。个人感觉Switch比较好看一些。

ToggleButton的截图:

Paste_Image.png

Switch 的截图:

Paste_Image.png
  <ToggleButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New ToggleButton"
        android:id="@+id/toggleButton"
        android:layout_below="@+id/radioGroup"
        android:layout_alignParentStart="true" />

    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="200dp"
        android:layout_marginTop="30dp"
        android:id="@+id/switch0"
        android:checked="true" />

另外,ToggleButton 与 Switch都需要实现各自的点击事件的处理,这里我就不多说了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,198评论 4 61
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,977评论 25 708
  • 1.坐车去学校,然后车晚点了。嗯,慢慢来,比较快。 2.在看书《精力管理》,已经看了一半多。 3.车上和老乡闲聊,...
    魏魏说阅读 138评论 0 1
  • 两点钟醒来 一直精神到现在 今天还能不能睡着 不知道 没有别的要求 明天不要爆表就好
    休憩中的猫阅读 169评论 0 0
  • display n.显示器,展示 v.展示,陈列+ reserved 预定的,保留 inex 下...
    YAN7阅读 351评论 0 1