I'm trying to change the colour of the action bar tabs programmatically. I have them by default in styles.xml as red, which is how I want them with the other tabs in my viewpager, however, on the first tab, I want both the action bar and the navigation tabs to become transparent. I've done this with the action bar by using this code
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
int newActionBarColor/*, newActionBarTabColor*/;
if(tab.getPosition() == 0) {
newActionBarColor = Color.parseColor("#" + Integer.toHexString(getResources().getColor(R.color.actionBarTransparent)));
//newActionBarTabColor = Color.parseColor("#" + Integer.toHexString(getResources().getColor(R.color.actionBarTabsTransparent)));
} else {
newActionBarColor = Color.parseColor("#" + Integer.toHexString(getResources().getColor(R.color.actionBar)));
//newActionBarTabColor = Color.parseColor("#" + Integer.toHexString(getResources().getColor(R.color.actionBarTabs)));
}
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(newActionBarColor));
//getSupportActionBar().setStackedBackgroundDrawable(new ColorDrawable(newActionBarTabColor));
//getSupportActionBar().setSplitBackgroundDrawable(new ColorDrawable(newActionBarTabColor));
mViewPager.setCurrentItem(tab.getPosition());
}
But I can't get this working with the tabs, any ideas? You can see what I've tried above.
Activity on tab where I want coloured tabs:
What I have currently on the tab where I want both the action bar and tab to be transparent: