Android的操作栏标签栏分隔 [英] Android action bar tab bar divider

查看:164
本文介绍了Android的操作栏标签栏分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题设置绘制的分频器。我style.xml看起来是这样的:

I am having problem setting the drawable for the divider. My style.xml looks like this:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="HCLTheme" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/HCLActionBarStyle</item>
        <item name="actionBarStyle">@style/HCLActionBarStyle</item>
        <item name="android:actionBarTabBarStyle">@style/HCLActionBarTabBarStyle</item>
        <item name="android:actionBarTabStyle">@style/HCLActionBarTabStyle</item>
    </style>

    <style name="HCLActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
        <item name="android:background">@drawable/hcl_actionbar_drawable</item>
        <item name="background">@drawable/hcl_actionbar_drawable</item>
        <item name="android:titleTextStyle">@style/HCLActionBarTitle</item>
    </style>

    <style name="HCLActionBarTabBarStyle" parent="@android:style/Widget.Holo.ActionBar.TabBar">
        <item name="android:showDividers">middle</item>
        <item name="android:divider">@drawable/divider</item>
        <item name="android:dividerPadding">0dp</item>
    </style>

    <style name="HCLActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
        <item name="android:background">@drawable/action_bar_tab_style</item>
    </style>

    <style name="HCLActionBarTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">@android:color/white</item>
    </style>

</resources>

在HCLActionBarTabBarStyle我设置@绘制器/分离器的标签分割。这是绘制一个9patch图像,垂直的黑线。

In the HCLActionBarTabBarStyle I'm setting the @drawable/divider as the tab divider. This drawable is a 9patch image, a vertical black line.

在我的XML设置分隔绘制我得到正常的白分是这样的:

Before i set the divider drawable in the xml I'm getting the normal white divider like this:

在我设置在styles.xml提拉我得到这样的:

After i set the drawable in the styles.xml i get this:

因此​​,大家可以看到刚刚获得更大了,它不是黑色的9patch图像垂直线分隔。我甚至不知道什么是绘制的分隔线是?图片或图层列表,或者可以说,它是一个颜色?其实我想这3个,但没有成功,所有的。

So as you can see the divider just gets wider, and its not the black vertical line from the 9patch image. I'm not even sure what the drawable for the divider has to be? A picture or layer list, or can it be a color? In fact i tried all of these 3 but with no success.

推荐答案

使用actionBarDivider财产上的自定义样式。

Use the property of "actionBarDivider" on the custom style.

类似下面

<style name="AppTheme" parent="AppBaseTheme">
     <!-- You app specific customization -->
     <item name="android:actionBarStyle">@style/MyActionBar</item>
     <item name="android:actionMenuTextColor">@color/menu_state_list</item>
     <item name="android:actionBarTabStyle">@style/tabStyle</item>
     <item name="android:actionBarTabTextStyle">@style/tabTextColor</item>

     <!-- Set it like this -->
     <item name="android:actionBarDivider">@drawable/verticle_marker_thin</item>
</style>

这篇关于Android的操作栏标签栏分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆