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 支持一下

相关推荐
TonyLee01719 小时前
Github使用记录
github
mygljx1 天前
MySQL 数据库连接池爆满问题排查与解决
android·数据库·mysql
放下华子我只抽RuiKe51 天前
从零构建高精度 AI Agent Skill:Tech Blog Generator 实战指南
人工智能·prompt·github·ai agent·skills·openclaw·development
xinhuanjieyi1 天前
ruoyimate导入sql\antflow\bpm_init_db.sql报错
android·数据库·sql
2401_884662101 天前
GitHub镜像站搭建全攻略大纲
github
散峰而望1 天前
【基础算法】从入门到实战:递归型枚举与回溯剪枝,暴力搜索的初级优化指南
数据结构·c++·后端·算法·机器学习·github·剪枝
闲猫1 天前
基于RABC的权限控制设计
android
Refly1 天前
【微信接入 OpenClaw 龙虾🦞】10分钟手把手教程完成接入,Claude 模型无限使用
前端·微信·github
老星*1 天前
Lucide Icons:开源、轻量、设计师友好的现代图标库
ui·开源·github
星霜笔记1 天前
GitMob — 手机端 GitHub 管理工具
android·kotlin·github·android jetpack