Reputation: 33
I want to change my application's theme in code , so i google it ...
Unfortunately, i can't find any method to **
.
**I don't want to set this attribute in xml like this...
<item name="colorAccent">@color/md_black</item>
or like this...
<item name="android:colorAccent">@color/md_black</item>
Plz help me...
Just tell me how...
Sorry for my poor english,i'm really not good at it...
Upvotes: 2
Views: 2872
Reputation: 2333
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>
Upvotes: 1