码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Android Material Design之SwitchMaterial(三)


    • 老规矩先上图
      在这里插入图片描述

    • 引入

    implementation 'com.google.android.material:material:1.4.0'
    
    • 1
    • 说明
      该控件就是Switch控件的增强版本,属性基本一致

    • 属性

      属性描述
      android:text文本
      android:textOn滑块打开时显示的文本
      android:textOff滑块关闭时显示的文本
      android:thumb滑块图片
      app:track轨迹图片
      app:switchMinWidth滑块开关的最小长度
      app:switchPadding滑块开关与文本的间距
      android:checked是否选中
      app:splitTrack是否将滑块与轨迹分开
      app:showText是否显示textOn/textOff 文本
      app:thumbTint设置滑块颜色
      app:trackTint设置轨迹颜色
      app:thumbTintMode用于应用滑动按钮色调的混合模式
    • 注意
      设置textOn/textOff 时一定要设置showText=“true”,否则没有效果

    • 源代码

    
    <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <com.google.android.material.switchmaterial.SwitchMaterial
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="开关"
            android:textOff="关"
            android:textOn="开"
            android:checked="true"
            app:showText="true"
            app:splitTrack="true"
            app:switchPadding="5dp"
            app:thumbTint="@color/black"
            app:trackTint="@color/design_default_color_error"/>
    androidx.coordinatorlayout.widget.CoordinatorLayout>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
  • 相关阅读:
    springboot整合swagger
    uview-plus的DatetimePicker如何只选年份?
    【Vue的初识--学习小结】
    kafka 相关概念
    MongoDB基础之查询文档操作
    Apache Airflow Celery Broker 远程命令执行 (CVE-2020-11981)漏洞复现
    一文讲解电源技术中专为准谐振转换器供电 高性能电流模式控制器NCP1380BDR2G
    HCIA证书能拿到的薪资高吗
    Spring源码-总体架构体系和源码环境搭建
    服务器硬件介绍(2)
  • 原文地址:https://blog.csdn.net/csdn_yang123/article/details/127999370
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号