Skip to content

BlurSwitchButtonView

Use Component

xml
<com.qmdeve.blurview.widget.BlurSwitchButtonView
    android:layout_width="65dp"
    android:layout_height="wrap_content"
    app:baseColor="#0161F2" />
java
// Create BlurSwitchButtonView instance
BlurSwitchButtonView blurSwitch = new BlurSwitchButtonView(context);

// Set layout parameters
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
    FrameLayout.LayoutParams.WRAP_CONTENT,
    FrameLayout.LayoutParams.WRAP_CONTENT
);
blurSwitch.setLayoutParams(params);

// Set attributes
blurSwitch.setBaseColor(0xFF0161F2);

// Add BlurSwitchButtonView to parent layout
parentLayout.addView(blurSwitch);

blurSwitch.setOnCheckedChangeListener(isChecked -> {
    // Handle switch state change
});
kotlin
// Create BlurSwitchButtonView instance
val blurSwitch = BlurSwitchButtonView(context)

// Set layout parameters
val params = FrameLayout.LayoutParams(
    FrameLayout.LayoutParams.WRAP_CONTENT,
    FrameLayout.LayoutParams.WRAP_CONTENT
)
blurSwitch.layoutParams = params

// Set attributes
blurSwitch.setBaseColor(0xFF0161F2)

// Add BlurSwitchButtonView to parent layout
parentLayout.addView(blurSwitch)

blurSwitch.setOnCheckedChangeListener { isChecked ->
    // Handle switch state change
}

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--

WARNING

BlurSwitchButtonView You only need to set the Base Color, and it will automatically calculate the color of the on and off state