截图


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