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.
I finally find a way to do that. Using this code in the onCreateView
method of the Fragment
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
View v = tabHost.getTabWidget().getChildAt(i);
v.setBackgroundResource(R.drawable.tabs);
TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(getResources().getColor(R.color.white));
}
And setting the bakcground color of the TabWidget
to red
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With