Android 集成与使用模糊开关按钮视图 (BlurSwitchButtonView)

截图


Demo与GitHub

Demo 下载

GitHub 仓库


快速集成

1. 添加仓库:

在项目根目录的 settings.gradle 中添加:

gradle 复制代码
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
       mavenCentral()
       maven { url 'https://jitpack.io' }
  }
}

2. 添加依赖:

在模块的 build.gradle 中添加:

gradle 复制代码
dependencies {
   implementation 'com.github.QmDeve:QmBlurView:v1.0.4.1'
}

快速使用

在XML布局中使用

xml 复制代码
<com.qmdeve.blurview.widget.BlurSwitchButtonView
        android:layout_width="65dp"
        android:layout_height="wrap_content"
        app:baseColor="#0161F2" />

属性说明

属性名 类型 默认值 说明
app:baseColor color #0161F2 基础颜色 (只需要设置基础颜色即可,会自动计算开启和关闭状态的颜色)

使用代码

java 复制代码
BlurSwitchButtonView blurSwitch = findViewById(R.id.blurSwitch);

// 回调开启和关闭状态
blurSwitch.setOnCheckedChangeListener(is -> {
    if (is) {
        
    }
});

// 设置基础颜色
blurSwitch.setBaseColor(0xFF0161F2);

// 第一个参数 设置状态,第二个参数 是否需要动画
blurSwitch.setChecked(false, false);

BlurSwitchButtonView 只需要设置基础颜色即可,会自动计算开启和关闭状态的颜色


详细请参考 Demo 点个 Star 支持一下

相关推荐
GoGeekBaird8 小时前
我开源了 BeeWeave,给 AI Agent 搭一个越用越懂你的知识创作台
后端·github
私人珍藏库8 小时前
[Android] PeakFinder AR v4.8.89 (山峰全景识别+增强现实山峰查看器)
android·人工智能·智能手机·ar·工具·软件
researcher-Jiang9 小时前
高性能计算之OpenMP——超算习堂学习1
android·java·学习
fthux10 小时前
GitZip Pro 源码解析:一个 GitHub 文件/文件夹下载扩展是如何工作的(一)整体架构与扩展入口
人工智能·ai·开源·github·open source
alexhilton10 小时前
Kotlin DSL深度解析:从Gradle脚本到构建你自己的DSL
android·kotlin·android jetpack
烽火聊员10 小时前
查看Android Studio错误日志
android·ide·android studio
第一程序员10 小时前
Rust Agent 子进程执行:Command 之前,先定义输入和超时
python·rust·github
2501_9369603612 小时前
GitHub初步了解
github
wangruofeng13 小时前
11 万 Star 的生成式 AI 入门课,Microsoft 做对了什么
github·aigc·ai编程
IOT那些事儿14 小时前
GitHub Profile 429: Too Many Requests
github·profile·429