0

我想自定义 sherlock 操作栏及其选项卡。

因为我必须显示大约 100-150dp 大小的应用程序图标图像,并且在应用程序图标的底部,我必须显示选项卡。

就像这样在此处输入图像描述

所以我在样式中尝试了这段代码

<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> 

等等。

这是我的活动代码

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

}


}

所以在这种情况下,我可以增加 Actionbar 的高度,但 ActionBar Tab 没有显示如何实现我想要的结果。

4

1 回答 1

0

最后我通过这种方式实现了愿望解决方案

<!-- 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>
于 2013-07-22T07:03:46.087 回答