How to change Android colors.xml to change based on user preference -


upon login, i'll returned user object on success , within object, i'm able tell type of user. want each user share same layouts different theme colors. there way declare multiple groups of colors inside colors.xml file? or have done creating whole different colors.xml file?

i have this:

for admin:

<resources>     <color name="primary">#e53935</color>     <color name="primary_dark">#b71c1c</color>     <color name="accent">#212121</color>     <color name="background_color">#f5f5f5</color>     <color name="text_color_primary">#fafafa</color>     <color name="drawer_fragment_background">#424242</color> </resources> 

for normal user:

<resources>     <color name="primary">#eeeee</color>     <color name="primary_dark">#bbbbb</color>     <color name="accent">#200001</color>     <color name="background_color">#c5bea3</color>     <color name="text_color_primary">#fafafa</color>     <color name="drawer_fragment_background">#424242</color> </resources> 

based on user object, want @color/primary point specific set of colors. done sharedpreference files?

i found solution guess have define different colors a_primary="#000" b_primary="#111" in colors.xml , can create different styles in styles.xml

<style name="a_theme" parent="apptheme">         <item name="colorprimary">@color/a_primary</item> </style>  <style name="b_theme" parent="apptheme">         <item name="colorprimary">@color/b_primary</item> </style> 

and apply theme according intent params oncreate settheme(android.r.style.a_theme);


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -