Search code examples
androidandroid-fragmentsandroid-actionbar

How to change Tab Indicator color programmatically


I am new to Android, and before starting programming i found that now a days many of the apps are using Fragments, especially Tab with Swipeable Views

How to change Tab Indicator/highlight color (I googled and changed ActionBar color to RED programmatically), but don't know how to change Tab Indicator color to RED. (priority programmatically)

still my ActionBar looks like this

I am using below lines to change background color of ActionBar, but i also need to change the color of Tab Indicator programmatically.

actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.RED));

Solution

  • I use Jeff Gilfelt,s Android Action Bar Style Generator. You can use GUI to style your tabs and at the end you get the source code which you can use, review and modify accordingly. :)

    Here's a link.

    http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=holo&theme=light&actionbarstyle=solid&texture=0&hairline=0&neutralPressed=1&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tabColor=33B5E5%2C100&tertiaryColor=F2F2F2%2C100&accentColor=33B5E5%2C100&cabBackColor=FFFFFF%2C100&cabHighlightColor=33B5E5%2C100