机器人:dividerPadding没有影响 [英] android:dividerPadding has no effect

查看:184
本文介绍了机器人:dividerPadding没有影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个题材的作品很好,引用三个自定义样式3部分ActionBar的标签。

但dividerPadding对任何人的任何影响 - 在17 API设备上运行

 <样式名称=Theme.AppEmptyTitleBar父=机器人:风格/ Theme.Holo>
        <项目名称=机器人:actionBarStyle> @风格/ AB< /项目>
        <项目名称=机器人:actionBarTabStyle> @风格/ ABT< /项目>
        <项目名称=机器人:actionBarTabBarStyle> @风格/ ABTB< /项目>
    < /风格><样式名称=AB父=机器人:风格/ Widget.Holo.ActionBar>
    <项目名称=机器人:dividerPadding> 20dip< /项目>
< /风格>
<样式名称=ABT父=机器人:风格/ Widget.Holo.Light.ActionBar.TabView>
    <项目名称=机器人:dividerPadding> 20dip< /项目>
< /风格>
<样式名称=ABTB父=机器人:风格/ Widget.Holo.ActionBar.TabBar>
    <项目名称=机器人:dividerPadding> 20dip< /项目>
< /风格>


解决方案

首先,在 dividerPadding 属性是(据我所知)仅适用于 * ActionBar.TabBar 的风格。

我一直在使用利用本机的一个非常基本的应用程序动作条和设备提供API 17.我已经将 dividerPadding 属性不同的价值观和留下默认值属性的其余部分。下面是结果:


  • dividerPadding =0dip


  • dividerPadding =15dip


  • dividerPadding =20dip

正如你所看到的,分走了最后一张图片上。所以我的第一个建议是要检查,如果你看到它。除此之外,在 dividerPadding 似乎运作正常。

我的第二个建议是来自Android平台的处理放置在不同的值作风资源的方式 - * 目录。我的直觉是,你可能会在默认的目录利用你的动作条样式。然后,如果您碰巧提供的这些样式的覆盖在值 - * 目录是兼容的(如值-VX 其中, X< = 17 ),从值的样式将被忽略。举个例子,假设您放置这些样品的风格在价值观/ styles.xml 文件:

 <资源的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <样式名称=AppTheme父=@安卓风格/ Theme.Holo>
        <项目名称=机器人:actionBarTabBarStyle> @风格/ ABTB< /项目>
    < /风格>    <样式名称=ABTB父=@安卓风格/ Widget.Holo.ActionBar.TabBar>
        <项目名称=机器人:dividerPadding> 0dip< /项目>
    < /风格>
< /资源>

如果你然后把这个样式定义值-V17 / styles.xml

 <资源的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <样式名称=AppTheme父=@安卓风格/ Theme.Holo>
    < /风格>
< /资源>

它会覆盖 AppTheme 风格,有效地复位(技术上:忽略)全 actionBarTabBarStyle 风格(包括 dividerPadding 属性值)。实际上,你不会看到的 ABTB 风格所做的任何更改。

修改

是啊,我以为你知道,抱歉:(本 dividerPadding 值仅适用于:


  • 顶和分频器当 TabWidget (它的标签页标签的容器)的底部绘制标签水平。

  • 左和分频器的右侧时, TabWidget 纵拉标签。

这正是你在截图看到。据我所知,你必须设置为绘制这将迫使更多的填充。我相信图层可绘制的将是巨大的,为此目的,因为你可以对每一层明确设置填充。

This theme works fine, referencing three custom styles for the 3 parts of the ActionBar's tabs.

But the "dividerPadding" has no effect on any of them - running on API 17 devices.

 <style name="Theme.AppEmptyTitleBar" parent="android:style/Theme.Holo">
        <item name="android:actionBarStyle">@style/AB</item>
        <item name="android:actionBarTabStyle">@style/ABT</item>
        <item name="android:actionBarTabBarStyle">@style/ABTB</item>
    </style>

<style name="AB" parent="android:style/Widget.Holo.ActionBar">
    <item name="android:dividerPadding">20dip</item>
</style>
<style name="ABT" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
    <item name="android:dividerPadding">20dip</item>
</style>
<style name="ABTB" parent="android:style/Widget.Holo.ActionBar.TabBar">
    <item name="android:dividerPadding">20dip</item>
</style>

解决方案

First of all, the dividerPadding attribute is (as far as I know) only applicable to the *ActionBar.TabBar style.

I've tested your style using a very basic application making use of the native ActionBar and a device providing API 17. I've set the dividerPadding attribute to different values and left the rest of the attributes with default values. Here are the results:

  • dividerPadding="0dip":

  • dividerPadding="15dip":

  • dividerPadding="20dip":

As you can see, divider is gone on the last image. So my first advice would be to check if you see it at all. Other than that, the dividerPadding seems to be working as expected.

My second advice comes from the way Android platform handles style resources placed in different values-* directories. My hunch is that you might be making use of your action bar styles in the default values directory. If you then happen to provide an override of these styles in a values-* directory which is compatible (e.g. values-vX where X <= 17), the styles from values will be ignored. As an example, consider that you've placed these sample styles in the values/styles.xml file:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="AppTheme" parent="@android:style/Theme.Holo">
        <item name="android:actionBarTabBarStyle">@style/ABTB</item>
    </style>

    <style name="ABTB" parent="@android:style/Widget.Holo.ActionBar.TabBar">
        <item name="android:dividerPadding">0dip</item>
    </style>
</resources>

If you then place this style definition in values-v17/styles.xml:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="AppTheme" parent="@android:style/Theme.Holo">
    </style>
</resources>

it will override the AppTheme style, effectively "resetting" (technically: ignoring) the whole actionBarTabBarStyle style (including the dividerPadding attribute value). In effect, you won't see any changes made to the ABTB style.

Edit

Yup, I assumed you know that, sorry :( The dividerPadding value applies only to:

  • Top and bottom of divider when the TabWidget (it's the container of tab labels) draws tabs horizontally.
  • Left and right sides of divider when the TabWidget draws tabs vertically.

Which is exactly what you see in the screenshots. As far as I know, you have to set divider to a drawable which will force additional padding. I believe the layer drawable will be great for that purpose because you can set padding explicitly for every layer.

这篇关于机器人:dividerPadding没有影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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