enricocid / ThemePreference

Custom preference to apply themes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ThemePreference

Custom preference to apply themes

ScreenShot

You can download the example APK from this repo here: https://github.com/enricocid/ThemePreference/raw/master/project/app/app-release.apk

Add the preference to your /res/xml/preferences.xml

<SwitchPreference android:defaultValue="false" 
android:key="pref_lightOrDark" 
android:title="@string/dark_theme"/>

<com.enrico.themepreference.ThemePreference 
android:defaultValue="0" 
android:key="pref_chooseAccent" 
android:persistent="true" 
android:summary="?attr/colorAccent" 
android:title="@string/pref_theme_title"/>

In Your activity

ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getBaseContext(), this.getTheme());

And use the util to apply the theme:

ThemeUtils.applyTheme(contextThemeWrapper, this);

About

Custom preference to apply themes

License:GNU Lesser General Public License v3.0


Languages

Language:Java 100.0%