Reputation: 1098
I am try to change the action bar background color for whole application but it required change in every activity. That why i want change style.xml file from my java code is there any way to this.please reply thank you in advance.
Upvotes: 1
Views: 1455
Reputation: 44118
Change the ActionBar background color programmatically:
getActionBar().setBackgroundDrawable(new ColorDrawable(0xff00DDED));
A good way would be to save your colors to res\colors.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="actionbar1">#FF6666</color>
<color name="actionbar2">#28B0DF</color>
</resources>
And then set your ActionBar background like this:
int color = getResources().getColor(R.color.actionbar1);
getActionBar().setBackgroundDrawable(new ColorDrawable(color));
Upvotes: 2