Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ActionBar tabs underline color programmatically

I have created the action bar by

ActionBar actionbar = getActionBar()

The background of the action bar is changed by

actionbar.setBackgroundDrawable(actionBarBackgroundImage);

Now I need to change the action bar tabs underline color programmatically. Is there any method to change the action bar tabs underline color?

like image 240
Karthick Avatar asked Apr 22 '13 04:04

Karthick


2 Answers

Alternatively you could use Android Action Bar Style Generator to easily theme your action bar and tabs.

like image 65
Litrik De Roy Avatar answered Oct 12 '22 20:10

Litrik De Roy


Here is a much easier way. I know you were looking for a programmatic change, but this one is REALLY easy.

I've been struggling with this for days, but finally found the solution. I'm using AppCompat. You can set colorAccent in your theme and that will change the highlight color on your ActionBar. Like so:

<item name="colorAccent">@color/highlightcolor</item>

Here it is in context:

<style name="LightTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/darkgrey</item>
    <item name="colorPrimaryDark">@color/black</item>
    <item name="colorAccent">@color/highlightcolor</item>
</style>

Where I originally posted this answer: Android Tab underline color not changing

like image 9
Kenny Wyland Avatar answered Oct 12 '22 20:10

Kenny Wyland