如何在TabActivity中为选项卡设置分隔符?

时间:2016-09-02 11:18:39

标签: android

我正在尝试在标签之间添加自定义分隔符。但它不起作用。这是我的java代码:

String tabschedule = getString(R.string.myschedule);
    mTabHost = getTabHost();
    intent = new Intent(this, Schedule.class);
    spec = mTabHost
            .newTabSpec("Schedule")
            .setIndicator(tabschedule,
                    this.getResources().getDrawable(R.drawable.schedule))
            .setContent(intent);
    mTabHost.addTab(spec);

    String filteration = getString(R.string.filteration);
    intent = new Intent(this, Filteration.class);
    spec = mTabHost
            .newTabSpec("Filteration")
            .setIndicator(filteration,
                    this.getResources().getDrawable(R.drawable.filteration))
            .setContent(intent);
    mTabHost.addTab(spec);

    String history = getString(R.string.history);
    intent = new Intent(this, MyHistory.class);
    spec = mTabHost
            .newTabSpec("History")
            .setIndicator(history,
                    this.getResources().getDrawable(R.drawable.historylay))
            .setContent(intent);
    mTabHost.addTab(spec);

这是我的xml代码:

 <style name="tabtheme" parent="@android:style/Theme.Light.NoTitleBar">
    <item name="android:actionBarTabBarStyle">@style/customTabBar</item>
</style>

<style name="customTabBar" parent="@style/Widget.AppCompat.ActionBar.TabBar">
    <item name="android:showDividers">middle</item>
    <!-- give your divider here -->
    <item name="android:actionBarDivider">@drawable/tabdivider</item>
    <item name="android:dividerPadding">0dp</item>
</style>

This is my screen shot

任何建议都将在此提前感谢。

0 个答案:

没有答案