Question

I'm using "Theme.AppCompat.Light" theme for my application in order to work with actionbar. I'm using android.support.v7 and this is the code I'm using for making the actionbar tabs :

    actionbar = getSupportActionBar();
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab tab1 = actionbar.newTab();
    tab1.setText("Tab 1");
    tab1.setTabListener(this);

    ActionBar.Tab tab2=actionbar.newTab();
    tab2.setText("Tab 2");
    tab2.setTabListener(this);

    ActionBar.Tab tab3=actionbar.newTab();
    tab3.setText("Tab 3");
    tab3.setTabListener(this);

    actionbar.addTab(tab1);
    actionbar.addTab(tab2);
    actionbar.addTab(tab3);

it works fine ( I wanted to post some images but I couldn't because of my reputation )

I wanna to do some customization like , change the height of tab , or when a tab is active, I wanna to change the background image and some other sort of thing .

what should I do ? or where I can see actionbar tab styles and do my cusotmization?

thanks alot

Was it helpful?

Solution

You need to create a custom theme and set it to the Activity or whole application in Manifest

Create a custom action bar tab style like this, and change the required attributes

    <style name="MyActionBarTabView" parent="Widget.AppCompat.Base.ActionBar.TabView">
   <item name="android:background">@drawable/action_bar_tab_background</item>
   </style> 

Create a custom theme like this, and change the actionBarTabStyle attribute.

  <style name="AppTheme" parent="Theme.Base.AppCompat">
   <item name="android:actionBarTabStyle">@style/MyActionBarTabView</item>
    <item name="actionBarTabStyle">@style/MyActionBarTabView</item>
    </style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top