2

I am using a TabLayout to switch between three tabs in my Android application. Each of the tabs contains a ListView with people information (that I've hidden in this screenshot).

screenshot of current result

I would like to know if there is a way to have a different background for each tab? I'm not talking about the background of the fragment here, but the background behind "TAB1" "TAB2" and "TAB3".

For example, i want something like that:

wanted result

I already tried to set a custom view and change its background, like this:

TabLayout.Tab memberTab = tabLayout.newTab();
memberTab.setText(R.string.tromb_tab1_title);
View v = new View(this);
v.setBackgroundColor(Color.RED);
memberTab.setCustomView(v);

But it only changes the color above the text "TAB1" and not the "tab rectangle" as a whole:

first try result

What can I do to obtain what I want?

Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
  • 1
    visit this : http://stackoverflow.com/questions/21335267/how-to-customize-individual-tabs-changing-background-color-indicator-color-an –  Mar 18 '16 at 14:29

0 Answers0