Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to customize android material color palette

Actually i am working on one android app which contains material design navigation drawer,i want to change the colors of status bar,action bar,text color dynamically for every 5 min.Actually i am using supporting library theme to support all android mobiles.So main thing is i want to customize color palette.Please help me to resolve this.

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- colorPrimary is used for the default action bar background -->
    <item name=”colorPrimary”>@color/my_awesome_color</item>

    <!-- colorPrimaryDark is used for the status bar -->
    <item name=”colorPrimaryDark”>@color/my_awesome_darker_color</item>

    <!-- colorAccent is used as the default value for colorControlActivated,
         which is used to tint widgets -->
    <item name=”colorAccent”>@color/accent</item>

    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight, and colorSwitchThumbNormal. -->

</style>
like image 750
peter Avatar asked Jan 21 '26 17:01

peter


1 Answers

What you're suggesting is possible using the method you're suggesting. Styles/themes/xml is static and can not be changed. To accomplish setting it dynamically, you'll have to get a reference to the widgets you want to change the background of and call the method to set the background of those items. For example:

Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
toolbar.setBackgroundResource(int);

Then you would just have to call this for every widget that you wanted to change the background of and on the root layout for your navigation drawer.

like image 165
MrEngineer13 Avatar answered Jan 23 '26 10:01

MrEngineer13



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!