如何风格冰淇淋三明治标签之间的分隔? [英] How to style the divider between Ice Cream Sandwich tabs?

查看:131
本文介绍了如何风格冰淇淋三明治标签之间的分隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一起用下面的风格,一套九片图像创建红线一些冰淇淋三明治的标签,而不是标准的蓝线的底部:

I'm using the following style together with a set of nine patch images to create a red line at the bottom of some Ice Cream Sandwich tabs instead of the standard blue line:

<style name="customTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabBar">
    <item name="android:tabStripLeft">@null</item>
    <item name="android:tabStripRight">@null</item>
    <item name="android:tabStripEnabled">false</item>
    <item name="android:showDividers">none</item>
    <item name="android:measureWithLargestChild">true</item>
    <item name="android:background">@drawable/tab_line</item>
    <item name="android:gravity">center</item>
</style>

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

<style name="LightThemeSelector" parent="android:Theme.Holo.Light">
    <item name="android:actionBarTabStyle">@style/customTabStyle</item>
    <item name="android:actionBarTabBarStyle">@style/customTabBar</item>
</style>

红线显示和everyting看起来不错,除了在标签之间的分隔。 正如你可以在图像内的绿色框看行不绘制下面的分隔。 如何选择一个可拉伸或样式这个分?

The red line is shown and everyting looks good, except for the divider between the tabs. As you can see inside the green box in the image the line is not drawn below the divider. How do I select a drawable, or a style for this divider?

安卓分安卓showDividers 项目是不负责的标签之间的分隔。他们只选择标签图标和分页标题之间绘制的分隔。我隐藏这些分频器,因为没有一个标题和一个除法会看起来很奇怪。

The android:divider and android:showDividers items are not responsible for the divider between tabs. They only select the divider drawn between the tab icon and the tab title. I hide those dividers because there isn't a title and a divider would look strange.

更新从Aneal记住我加了第二个样式customTabBar答案。风格选择绘制作为分隔。分频器与以下9patch绘制创建了一个黑色实线:

Update With the answer from Aneal in mind I added a second style customTabBar. The style selects a drawable as a divider. The divider is a solid black line created with the following 9patch drawable:

通过这种绘制分频器绘制,但也有一个空行旁边:

With this drawable the divider is drawn, but there is also a blank line next to it:

推荐答案

去除各种风格我用我得到了下面的图像后:

After removing every style I use I got the following image:

这形象也包含了小的差距。因此看来,这是某种形式的默认行为。

This image also contains the small gaps. Therefore it seems that this is some kind of default behavior.

不过,我找到了一种方法来解决这个问题。我设置了红线作为一个标准的背景为整个的TabBar。这种方式出现的差距,但没有人能看到它,因为背景,已包含该行显示。

However I found a way to work around the problem. I set the redline as a standard Background for the whole tabbar. This way the gap appears but nobody can see it because the background, that already contains the line is shown.

我现在使用下面的风格为我所有的活动:

I now use the following style for all my activities:

<style name="LightThemeSelector" parent="android:Theme.Holo.Light">
    <item name="android:actionBarTabBarStyle">@style/customTabBar</item>
    <item name="android:actionBarTabStyle">@style/customTabStyle</item>
</style>

这种风格用于样式化的TabBar内的每个单独的标签:

This style is used to style each single tab inside the tabbar:

<style name="customTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:showDividers">none</item>
    <item name="android:measureWithLargestChild">true</item>
    <item name="android:background">@drawable/tab_line</item>
    <item name="android:gravity">center</item>
</style>

款式全的TabBar我用下面的方式:

To style the whole Tabbar i use the following style:

<style name="customTabBar" 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>
    <item name="android:background">@drawable/tab_unselected</item>
</style>

这风格的定义我自定义分并且还定义了背景的的TabBar。作为背景我直接设置九个补丁绘制如果标签没有被选中的绘制。 所有这一切的结果是用红色下划线没有任何间隙的的TabBar。

This style defines my custom divider and also defines the background for the tabbar. As background I directly set the nine patch drawable that is drawn if a tab is not selected. The result of all this is a tabbar with a red underline without any gaps.

这篇关于如何风格冰淇淋三明治标签之间的分隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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