Un guide rapide pour utiliser les composants de matériaux dans Android
... ...>
android:theme="@style/Theme.Zimgur.DayNight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/coverImage">android:id="@+id/chipGroup"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:singleLine="true">
setSafeOnClickListener {toggleTheme(isDarkTheme(this@MainActivity))}
private fun toggleTheme(isDark: Boolean): Boolean {
val mode = when (isDark) {
true -> LIGHT_MODE
false -> DARK_MODE
}
ThemeManager.applyTheme(mode)
preferenceManager.saveThemePreference(mode)
return true
}