【问题标题】:Styling the Actionbarsherlock tabs设置 Actionbarsherlock 选项卡的样式
【发布时间】:2012-05-04 07:48:34
【问题描述】:

所以我正在尝试设置我使用 ActionBarSherlock 库实现的 Actionbar 选项卡的样式。这是我的代码:

<style name="Theme.AndroidDevelopers" parent="Theme.Sherlock.Light.ForceOverflow">
                <item name="actionBarTabStyle">@style/CustomActionBarStyle</item>
                <item name="android:actionBarTabStyle">@style/CustomActionBarStyle</item>

            <style name="CustomActionBarStyle" parent="Widget.Sherlock.Light.ActionBar.TabBar">
                <item name="android:background">@drawable/actionbar_tab_bg</item>
            </style>

在第二行和第三行,如果我将 actionBarTabStyle 更改为 actionBarStyle,我的操作栏本身会更改为我想要的样式(当然不是很好),所以连接确实有效。但是,尝试更改操作栏选项卡(在其下方)仍然没有成功。

我希望有人可以帮助我。

问候,

【问题讨论】:

  • 你检查过style的开始和结束标签了吗?

标签: android styles themes android-actionbar actionbarsherlock


【解决方案1】:

以下应该可以工作

<style name="Theme.app" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarTabBarStyle">@style/Theme.app.tabbar.style</item>
        <item name="actionBarTabBarStyle">@style/Widget.app.ActionBar.TabBar</item>
</style>

<style name="Theme.app.tabbar.style" parent="@style/Theme.Sherlock.Light">
    <item name="android:background">#FF0000</item>
    <item name="background">#FF0000</item>
</style>

<style name="Widget.app.ActionBar.TabBar" parent="Widget.Sherlock.ActionBar.TabBar">
    <item name="android:background">#FF0000</item>
    <item name="background">#FF0000</item>
</style>

这会使 tabBar 变成红色。

你需要设置两次actionBarTabBarStyle。这是因为 Android > 3.0 和 Android

【讨论】:

【解决方案2】:

在你的CustomActionBarStyle你需要有

<item name="android:background">@drawable/actionbar_tab_bg</item>
<item name="background">@drawable/actionbar_tab_bg</item>

希望这会有所帮助:)

【讨论】:

  • 感谢您的回复。但是,它仍然不适用于您的建议。我真的不知道这里有什么问题。
  • 您是否尝试过使用父级Widget.Sherlock.Light.ActionBar.TabView
【解决方案3】:

所以我在样式方面遇到了一些困难,因为我发现首先通过代码添加选项卡的某种方式。感谢您的回复,它们都有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-28
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多