在 Android 的 Sherlocks 库中更改 ActionBar 中选项卡的背景颜色? [英] Change background color of Tabs in ActionBar in Sherlocks library in Android?

查看:13
本文介绍了在 Android 的 Sherlocks 库中更改 ActionBar 中选项卡的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Sherlock 库开发 Actionbar.我想以不同的方式更改操作栏和选项卡的背景图像.目前我已经在运行时通过代码成功更改了操作栏的背景:

I am working on Actionbar using Sherlock library. I want to change the Background Image of the Actionbar and Tabs differently. Currently I have changed the Background of the Actionbar successfully via codes at runtime:

Drawable myIcon = getResources().getDrawable(R.drawable.blue_menu_background);
mActionBar.setBackgroundDrawable(myIcon);

但是我遇到了标签背景的问题.如何更改选项卡的背景.请给我建议.

But I am getting problem with the Tab background. How can I change the Background of Tabs. Please suggest me.

推荐答案

您可以使用 Style for Tabs 来代替:

Instead of doing that, you can use Style for Tabs:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
        <item name="android:actionBarTabTextStyle">@style/CustomTabTextStyle</item>
        <item name="android:actionBarDivider">@drawable/ab_divider</item>
        <item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
    </style>

    <!-- style for the action bar tab text -->
    <style name="CustomTabTextStyle" parent="@android:style/TextAppearance.Holo">
        <item name="android:textColor">#2456c2</item>
    </style>
</resources>

查看此文章了解更多详情.

这篇关于在 Android 的 Sherlocks 库中更改 ActionBar 中选项卡的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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