This library implements Material 3 Preference theme by extending AndroidX preference theme.
dependencies {
implementation "dev.rikka.rikkax.material:material-preference:<version>"
}
Add to your theme:
<!-- Extend this style if you have other custom preferences -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Rikka.Material3</item>
Apply this style after super.onCreate
in your settings Activity:
context.getTheme().applyStyle(rikka.material.preference.R.style.ThemeOverlay_Rikka_Material3_Preference, true);
- (Breaking change) Use Material 3 style rather than system settings style
- Add
rikka.material.preference.MaterialSwitchPreference
which usesMaterialSwitch
from Material Components 1.7.0
Note, current version of Material Components (1.7.0-alpha02) requires the user to add <item name="materialSwitchStyle">@style/Widget.Material3.CompoundButton.MaterialSwitch</item>
to the theme. If you are using dev.rikka.rikkax.material:material
v2.5.0+, this has been already done.
- Port Preference style from Android 12 system settings