夏洛克操作栏标签的文字自定义颜色 [英] Tabs text custom color in Sherlock Action Bar

查看:193
本文介绍了夏洛克操作栏标签的文字自定义颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改标签的颜色,在操作栏取决于标签是否选择或不?

How can I change the colors of the tabs in the Action Bar depending on whether a tab is selected or not?

这应该是这样的:黑色选中时,当未选中/非那种棕色

It should look like this: black when selected, and that kind of brown when not selected/inactive.

我试图将其设置在styles.xml,但我找不到合适的名字,使其工作。

I tried to set it in the styles.xml but I couldn't find the proper name to make it work.

非常感谢您的帮助!

编辑:我使用的是下面这段code为TabsListener

I'm using the following piece of code for the TabsListener

class MyTabsListener implements TabListener {
        private Fragment fragment;

        public MyTabsListener(Fragment ef) {
            this.fragment = ef;
        }

        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            ft.replace(R.id.realtabcontent, fragment);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        }

        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        }

        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }
    }

推荐答案

其实,这是pretty的easy.All你应该做的是这样定义的属性。

In fact it is pretty easy.All you should do is defining an attribute like this

<style name="tabtextcolor" parent="@style/Widget.Sherlock.ActionBar.TabText">
    <item name="android:textColor">@android:color/white</item>
</style>

然后

将这些样式应用到主题

<item name="actionBarTabTextStyle">@style/tabtextcolor</item>
<item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>

这篇关于夏洛克操作栏标签的文字自定义颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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