Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ActionBar Tab Color

Tags:

I have added ActionBar tabs to my application. Default color for that underline is light blue. How do I change that color or style for selected tab ?

like image 485
user533844 Avatar asked Sep 28 '11 14:09

user533844


3 Answers

For anyone wants to change actionbar color/background in code, you can do something like this

final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar_bg));

To change the tab bar color under the actionbar:

actionBar.setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.color_brown_dark)));

To change tab bar background:

actionBar.setStackedBackgroundDrawable(getResources().getDrawable(
            R.drawable.coupon_header));
like image 63
thomasdao Avatar answered Oct 05 '22 23:10

thomasdao


This may give some clues Action Bar Style Gen

like image 25
Dori Avatar answered Oct 06 '22 01:10

Dori


selectableItemBackground is the attribute I think your looking for. I'd recommend you read this article about Customizing the Action Bar as well as look at this question on SO and this one as well.

In code i cant seem to find a way to customize the individual item selected but , customizing the bar itself would look something like this.

ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("FF0000"));
like image 32
Terrance Avatar answered Oct 06 '22 00:10

Terrance