How to set colorAccent in code?

后端 未结 1 1454
傲寒
傲寒 2021-01-16 12:21

I want to change my application\'s theme in code , so i google it ...
Unfortunately, i can\'t find any method to **

set colorAccent in java code

相关标签:
1条回答
  • 2021-01-16 13:15

    You can not do this via code.

    You can set a default theme with this attribute.

    In the activity where you want to change the color, simply create another theme that inherits the default theme, but this new theme you put another color for coloAccent

    Default Theme:

        <item name="colorPrimary">@color/default_color_app</item>
        <item name="colorPrimaryDark">@color/default_color_app_dark</item>
        <item name="colorAccent">@color/default_color_app_dark</item>
    

    Another Activity:

    <style name="BaseTheme.AnotherActivity" parent="BaseTheme">
       <item name="colorAccent">@color/another_color</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题