Android 3.0 ActionBar, changing colors

╄→гoц情女王★ 提交于 2019-11-28 20:48:24

You can control the appearance of the tabs by using the properties android:actionBarTabStyle, android:actionBarTabBarStyle, and android:actionBarTabTextStyle.

This section in the official developer guide shows a sample xml to customize the action bar's style.

Regarding the text of the menu options check the properties actionMenuTextAppearance and actionMenuTextColor.

As additional info, here's how I found out how to change the blue bar below each tab (the answer above is perfectly good, but I lacked little information that I put here, which might be useful to somebody).

You just need to change the background to a 9 patch drawable.

Here's how it looks like:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html

Source available here:
http://code.google.com/p/styled-action-bar/source/browse/trunk/res/drawable/actionbar_tab_bg.xml

9 patches available here:
http://code.google.com/p/styled-action-bar/source/browse/trunk/res/drawable-mdpi

I know this was really easy, but again, it might be useful so I'm just dropping the links here.

None of these solutions worked for me. I changed the colors of my tabs as follows:

This is in the themes.xml

<style name="MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarTabTextStyle">@style/MyApp.ActionBar.MyTabStyle</item>
</style>

This is in styles.xml

<style name="MyApp.ActionBar.MyTabStyle" parent="android:style/Widget.Holo.ActionBarView_TabText">
    <item name="android:textColor">#00ff00</item>
</style>

This should make your tabs green.

I think that you can use:

<resources>
    <style name="MyTheme" parent="android:style/Theme.Holo.Light">
        <item name="android:actionMenuTextColor">@color/...</item>
    </style>
</resources>

Regards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!