Skip to main content

BlurSwitchButtonView


BlurSwitchButtonView

Used in XML layout

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

Attribute Description

Attribute NameTypeDefault ValueDescription
app:baseColorcolor#0161F2Base Color (you only need to set one color value, and it will automatically calculate the color of on and off states)
app:useSolidColorModebooleanfalse-
app:solidOnColorcolor--
app:solidOffColorcolor--

Use the code

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

// Callback on and off status
blurSwitch.setOnCheckedChangeListener(is -> {
    if (is) {
        
    }
});

// Set Base Color
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 You only need to set the Base Color, and it will automatically calculate the color of the on and off state