colors - How to set theme dynamically coming from server ANDROID -


i getting color codes in server , have set theme. know can individually setting colors on each element. there way create theme dynamically or declare colors of theme programmatically. main aim group of users can set own theme.

  private void setcolors(colors color) {   int toolbarcolor = 0;   int statusbarcolor = 0;   switch (color) {       case green:           settheme(r.style.apptheme_noactionbar_green);           toolbarcolor = r.color.green;           statusbarcolor = r.color.greendark;           break;       case red:           settheme(r.style.apptheme_noactionbar_red);           toolbarcolor = r.color.red;           statusbarcolor = r.color.reddark;           break;       case blue:           settheme(r.style.apptheme_noactionbar_blue);           toolbarcolor = r.color.blue;           statusbarcolor = r.color.bluedark;           break;   }   mtoolbar.setbackgroundcolor(contextcompat.getcolor(mainactivity.this, toolbarcolor));   if (build.version.sdk_int >= build.version_codes.lollipop) {       getwindow().setstatusbarcolor(contextcompat.getcolor(mainactivity.this, statusbarcolor));   } } 

currently, doing modules, in project increases, find difficult or hectic this. looking else setting theme colors programmatically.

thank in advance helping me out


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -