使用Actionbarsherlock时,我目前无法在我的应用程序中自定义选项卡指示符。我正在尝试将指示器的默认颜色(蓝色)更改为白色。所有其他定制均按预期工作。我什至无法删除制表符指示符。我是否错过了XML代码中的某些内容,或者可能是问题所在?还要注意,清单文件中我的min-SDK设置为14。需要所有帮助,因此我可以设法找到问题的根源:/

Tabs.java

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab_host);

ActionBar actionBar = getSupportActionBar();
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setTitle(R.string.LabelTitleAbout);


            actionBar.addTab(actionBar.newTab().
                setTabListener(new TabListener<LandingSearch>(this, getString(R.string.LabelSearchTabTitle), LandingSearch.class, null)));

the code continues with the constructor etc...


tab_host.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <LinearLayout
        android:id="@+id/tabs_navigation_content"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </LinearLayout>
</LinearLayout>


values / themes.xml

<style name="Theme.ML" parent="@style/Theme.Sherlock">
    <item name="windowNoTitle">true</item>
    <item name="android:actionBarTabBarStyle">@style/Theme.ML.Tabs</item>
     <item name="actionBarTabBarStyle">@style/Theme.ML.Tabs</item>
</style>

<style name="Theme.ML.Tabs" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="windowNoTitle">true</item>
    <item name="background">@drawable/tab_bar_background</item>
    <item name="android:background">@drawable/tab_bar_background</item>

</style>
...


drawable / tab_bar_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/menu_blank_off"/>
  <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_bar_background_selected"/>
  <item android:state_selected="false" android:state_pressed="true" android:drawable="@color/white"/>
  <item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_bar_background_selected_pressed"/>
</selector>


tab_bar_background_selected.xml

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="-5dp" android:left="-5dp" android:right="-5dp">
        <shape android:shape="rectangle">
            <stroke android:color="#ffffff" android:width="5dp"/>

        </shape>
    </item>
</layer-list>

最佳答案

您可以使用操作栏样式生成器来完全自定义操作栏样式,这里是操作栏样式生成器的链接:
Action Bar Style Generator

您也可以从以下示例中进行操作:-Customize Action bar

关于android - 使用ActionBarSherlock样式化tabBar指示器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23848214/

10-11 20:16