Android 12 Developer Preview is here! Try it out, and give us your feedback!

MaterialCheckBox

public class MaterialCheckBox
extends AppCompatCheckBox

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.Button
         ↳ android.widget.CompoundButton
           ↳ android.widget.CheckBox
             ↳ androidx.appcompat.widget.AppCompatCheckBox
               ↳ com.google.android.material.checkbox.MaterialCheckBox


A class that creates a Material Themed CheckBox.

This class uses attributes from the Material Theme to style a CheckBox. Excepting color changes, it behaves identically to AppCompatCheckBox. Your theme's ?attr/colorControlActivated, ?attr/colorSurface, and ?attr/colorOnSurface must be set.

Summary

Inherited constants

Inherited fields

Public constructors

MaterialCheckBox(Context context)
MaterialCheckBox(Context context, AttributeSet attrs)
MaterialCheckBox(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

boolean isUseMaterialThemeColors()

Returns true if this MaterialCheckBox defaults to colors from a Material Theme.

void setUseMaterialThemeColors(boolean useMaterialThemeColors)

Forces the MaterialCheckBox to use colors from a Material Theme.

Protected methods

void onAttachedToWindow()

Inherited methods

Public constructors

MaterialCheckBox

public MaterialCheckBox (Context context)

Parameters
context Context

MaterialCheckBox

public MaterialCheckBox (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MaterialCheckBox

public MaterialCheckBox (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

isUseMaterialThemeColors

public boolean isUseMaterialThemeColors ()

Returns true if this MaterialCheckBox defaults to colors from a Material Theme.

Returns
boolean

setUseMaterialThemeColors

public void setUseMaterialThemeColors (boolean useMaterialThemeColors)

Forces the MaterialCheckBox to use colors from a Material Theme. Overrides any specified ButtonTintList. If set to false, sets the tints to null. Use AppCompatCheckBox.setSupportButtonTintList(ColorStateList) to change button tints.

Parameters
useMaterialThemeColors boolean

Protected methods

onAttachedToWindow

protected void onAttachedToWindow ()