I've a TabWidget
, independently of the ÀctionBar, in a
FragmentTabHost`.
I want to customize the look and feel of the TabWidget
but I don't get it. My intention is to change the text color and the selector color, as you can see in the image I can change the background of the TabWidget
. I don't want to use a custom TextView
for the tabs because the tabs must be with the Holo look and feel.
I've tried to put a style to the TabWidget
but it doesn't work. In this way:
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@style/MyTabs"
/>
and with the style
<style name="MyTabs">
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/tabs</item>
<item name="android:backgroundStacked">@color/red_action_bar</item>
</style>
I've tried to add the style from a theme.xml using theparent="android:Widget.Holo.TabWidget"
, but nothing happens.
As I answered here, this can actually be done using XML themes. The
TabWidget
usesandroid:textPrimaryColor
for the selected tab andandroid:textSecondaryColor
for the unselected ones. The accent color is determined bycolorAccent
and the background color bycolorPrimary
Thus, you can achieve the desired customization like this:In styles.xml:
In your layout:
Note that the
android:theme
should not be directly in theTabWidget
itself, but rather the containingTabHost
or similar.I finally find a way to do that. Using this code in the
onCreateView
method of theFragment
And setting the bakcground color of the
TabWidget
to redTry this:
1.Create a new style:
2.On Tab Host, set theme:
3.The background you can set normally on TabWidget
I have not changed the tabs themselves, but I would assume that you can do it with these styles from styles.xml...
with tab_indicator_holo.xml
Or you may also try
and tab_indicator_ab_holo.xml
Finally using the two png-9 drawables: tab_selected_holo and tab_unselected_holo. They look like the two thicker and thinner blue lines you are talking about.
Or do you mean the minitabs?
with in minitab_lt.xml
If you need another definition just search for TabWidget in here: https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml
Then as usual define your own style with all the required attributes and drawables...