I'm trying to change the action bar's background (ABS 4.2) when I navigate from page 1 to 2 of a ViewPager
.
I've tried setTheme(R.style...)
but as it says on the docs it should be called before the view is drawn. In fact I'm getting no changes at all.
I've created the theme using this and I want to switch between the solid and the transparent action bar style.
On the setTheme(int)
I'm not using the int
of the style, I've created a new theme that overrides only the android:actionBarStyle
and actionBarStyle
with the transparent drawable.
Is there a way to change the color on the fly?
Just create your background as a drawable xml (or it can be a color if you want a simple color). And then use setBackgroundDrawable(drawable)
method.
Look here: How do I make an ActionBar with a background like the YouTube app
and here: ActionBar setBackgroundDrawable() nulling background from Thread/Handler