码农知识堂 - 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
  • 相关阅读:
    深入讲解Netty那些事儿之从内核角度看IO模型(下)
    ThreeJS 第二篇:顶点概念、几何体结构
    DockerCompose - 部署 Nexus 私服
    电脑异常关机录屏/软件/程序异常停止/安卓手机/数据丢失找回方案
    JVM在线分析-解决问题的工具二(jcmd, jdb, jhsdb)
    linux如何运行c程序命令
    隧道HTTP API使用教程
    Git链接上游仓库
    基于Struts2+JavaBean+JSP+MySQL的宿舍寝室管理系统设计与实现
    “控制情绪,理性交流”刍议
  • 原文地址: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号