Home » Android » android – Custom style for stacked action bar?

android – Custom style for stacked action bar?

Posted by: admin June 15, 2020 Leave a comment


I want to have separate backgrounds for stacked and non-stacked tab bars.

This should explain it:

enter image description here

So the way I have it is:

For tablets, use dark background tabs. For everything else, use light background.

This covers most use cases, but I’d like to make it not look bad in phone-landscape.

Any way I can do this? A style modifier I missed, maybe?

How to&Answers:

You can change the tab background depending on stacked/non-stacked ActionBar by setting the light background drawable only for android:backgroundStacked in your theme.

But then you run into the problem that you can’t define the tab text color based on stacked/non-stacked layout. That means, the result is either light text on light background or dark text on dark background.

This is already a registered issue: http://code.google.com/p/android/issues/detail?id=26557, so your options now are either waiting or using one of these workarounds:

P.S. I’m also facing this issue as I have a dark ActionBar with light tabs in my app. Still haven’t found the perfect solution.

A little off-topic: If you haven’t already, use the Action Bar Style Generator to deal with colors and drawables easier. Again, you’ll find no satisfactory configuration for a dark action bar with a light stacked tab bar.