Search code examples
androidtabsactionbarsherlockandroid-actionbar

Sherlock actionbar tab not shown when increase the actionbar size


I want to customize the sherlock actionbar and its tab.

As I have to show an app icon image in approximate 100-150dp size and bottom the app icon i have to display tab.

Just like this way enter image description here

So I tried this code in styles

<style name="Theme.Style.Login" parent="@style/Theme.Sherlock.Light">
<!-- For API level <11--->
    <item name="actionBarStyle">@style/Theme.white_style</item>
    <item name="actionBarTabStyle">@style/customLoginActionBarTabStyle</item>
    <item name="actionBarTabBarStyle">@style/customLoginActionBarTabDividerStyle</item> 
<!-- For API level <11--->

<!-- For API level >=11--->
     <item name="android:actionBarTabBarStyle">@style/customLoginActionBarTabStyle</item>
     <item name="android:actionBarStyle">@style/Theme.white_style</item> 
    <item name="android:actionBarTabBarStyle">@style/customLoginActionBarTabDividerStyle</item>
 <!-- For API level >=11--->
</style>

<!-- Signup Login Tab Style theme -->
<style name="customLoginActionBarTabStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
    <item name="android:background">@drawable/actionbar_tabs_selector_loginsignup</item>

</style> 
<style name="customLoginActionBarTabDividerStyle" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="divider">@null</item>
    <item name="android:divider">@null</item>
</style> 



<style name="Theme.white_style" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarSize">@dimen/loginactionbar</item>
    <item name="android:actionBarSize">@dimen/loginactionbar</item>
</style> 

and so on.

And here is my activity code

public class SignupLoginActivity extends SherlockActivity implements ActionBar.TabListener {

public static int THEME = R.style.Theme_Style_Login;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(THEME); 
    setContentView(R.layout.main);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setCustomView(R.layout.login_actionbar_customeview);
     actionBar.setDisplayShowTitleEnabled(false);
     actionBar.setDisplayShowCustomEnabled(true);

     actionBar.setLogo(null); 

     View homeIcon = findViewById(
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? 
             android.R.id.home : R.id.abs__home);
     ((View) homeIcon.getParent()).setVisibility(View.GONE);
     ((View) homeIcon).setVisibility(View.GONE);

     /*
         * For adding tab
         */
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        for (int i = 1; i <= 2; i++) {     
            ActionBar.Tab tab = actionBar.newTab();
            tab.setText("Tab " + i);
            tab.setTabListener(this);
            actionBar.addTab(tab);
        }
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // TODO Auto-generated method stub

}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    // TODO Auto-generated method stub

}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
    // TODO Auto-generated method stub

}


}

So in this case I am able to increase Actionbar height but ActionBar Tab are not showing so how to achieve the result which i want.


Solution

  • Finally I achived the desire solution by this way

    <!-- For API Level <11 -->
     <style name="Theme.Style.Login" parent="@style/Theme.Sherlock.Light">
        <item name="actionBarTabStyle">@style/customLoginActionBarTabStyle</item>
        <item name="actionBarDivider">@null</item>   // This will remove divider between tabs
        <item name="actionBarTabTextStyle">@style/customeLoginTabTextStyle</item> // This will increase tab text size
        <item name="actionBarSize">@dimen/loginactionbar</item> // This will increase actionbar size
     </style>
    <!-- For API Level <11 -->
    
    <!-- For API Level >=11 -->
     <style name="Theme.Style.Login" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarTabStyle">@style/customLoginActionBarTabStyle</item>
        <item name="actionBarDivider">@null</item>   // This will remove divider between tabs
        <item name="android:actionBarTabTextStyle">@style/customeLoginTabTextStyle</item> // This will increase tab text size
        <item name="android:actionBarSize">@dimen/loginactionbar</item> // This will increase actionbar size
     </style>
     <!-- For API Level >=11 -->
    
    
    <!-- For API Level >=14 -->
     <style name="Theme.Style.Login" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarTabStyle">@style/customLoginActionBarTabStyle</item>
        <item name="android:actionBarDivider">@null</item>   // This will remove divider between tabs
        <item name="android:actionBarTabTextStyle">@style/customeLoginTabTextStyle</item> // This will increase tab text size
        <item name="android:actionBarSize">@dimen/loginactionbar</item> // This will increase actionbar size
     </style>
     <!-- For API Level >=14 -->
    
    <!-- Signup Login Tab Style theme -->
    <style name="customLoginActionBarTabStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
        <item name="android:background">@drawable/actionbar_tabs_selector_loginsignup</item>
        <item name="android:paddingTop">20dp</item>
    </style> 
    
    <style name="customeLoginTabTextStyle" parent="Widget.Sherlock.ActionBar.TabText">
        <item name="android:textColor">@color/countryname</item>
        <item name="android:textSize">@dimen/logintabtxtsize</item>
    </style>