My customized checkbox (MyCheckbox
) has extended from androidx.appcompat.widget.AppCompatCheckBox
, but the default styles don\'t apply to it.
The MaterialCheckBox
provided by the Material Components library uses the checkboxStyle
attribute defined in the theme.
Just override this attribute to define globally the style in your app:
If you want to customize the color you can use the materialThemeOverlay
attribute in the style:
with:
You can also apply the style to the single checkbox using:
As alternative you can also use the android:theme
in the layout, but it doesn't work globally.
Just a note.
The colorTint selector is defined programmatically in the MaterialCheckBox
code. You can also define a custom colorTint selector adding the buttonTint
attribute in your custom style. In this case the colors defined above are ignored.