I have an ActionBarActivity
which has fragments for a navigation drawer. When an item in the navigation drawer is pressed, it starts the corresponding fragment.
In each of these fragments, the onCreate()
method looks like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setTheme(R.style.AppTheme);
setHasOptionsMenu(true);
}
The theme that is applied is different for each of these fragments however.
I noticed that the setTheme()
method does not appear to change the colour of the ActionBar
or status bar as declared in the styles.xml
from which I am referencing:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/brand_red_primary</item>
<item name="colorPrimaryDark">@color/brand_red_primaryDark</item>
<item name="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>
Again, there are different styles with different colorPrimary
and colorPrimaryDark
attributes for the different fragments in my activity.
So, the setTheme()
method does not change the colour of the ActionBar
or status bar, but it does change some things like the colour of the pullback feature in a listview, for example.
Am I missing something, or is there something I need to do for setTheme()
to change the ActionBar
and status bar colour?
UPDATE:
I tried the solution posted here but it gives me exactly the same result as what I had tried before (using setTheme()
).