Skip to content

BlurSwitchButtonView

在XML布局中使用

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

属性说明

属性名类型默认值描述
app:baseColorcolor#0161F2基础颜色 (你只需要设置一个颜色值,它会自动计算 onoff 状态的颜色)
app:useSolidColorModebooleanfalse-
app:solidOnColorcolor--
app:solidOffColorcolor--

Use the code

java
BlurSwitchButtonView blurSwitch = findViewById(R.id.blurSwitch);

// 设置回调监听器
blurSwitch.setOnCheckedChangeListener(is -> {
    if (is) {
        
    }
});

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

// The first parameter sets the status, and the second parameter determines whether an animation is needed
blurSwitch.setChecked(false, false);

// Use the solid color mode
blurSwitch.setUseSolidColorMode(true);

// Is it in solid color mode
blurSwitch.isUseSolidColorMode();

// Set the color of the solid color mode
blurSwitch.setSolidColors();

WARNING

BlurSwitchButtonView 你只需要设置基础颜色,会自动计算 onoff 状态的颜色