A CheckBox
represents a button with two states, selected and unselected.
Unlike radio buttons, changes in the states of one checkbox do not usually
affect other checkboxes. A checkbox is a rounded square button with a check to
denote its current state.
The MaterialCheckBox
widget provides a complete implementation of Material
Design's checkbox component. It is auto-inflated when using a non-Bridge
Theme.MaterialComponents.* theme which sets the MaterialComponentsViewInflater.
Example code of how to include the widget in your layout:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Using a Material Components theme with MaterialCheckBox
will match the color
of CheckBox
views to your theme's palette. If you want to override this
behavior, as you might with a custom drawable, set the useMaterialThemeColors
parameter to false.
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:useMaterialThemeColors="false"/>
Use checkboxStyle
for style changes.
<item name="checkboxStyle">@style/Widget.MaterialComponents.CompoundButton.CheckBox</item>