The FragmentTabHost
returns the TabWidget
(only one), which is the View
responsible for drawing those tabs. Every child of him is a different flap.
The color setting of Tab
of Style Generator
applies only to Tab
of ActionBar
.
In your case you are using TabHost
and TabWidget
, and this style does not apply to them unfortunately.
To customize the tab, you need to retrieve TabWidget
and stylize each child. This way:
// Assim como voce mencionou
TabWidget tabWidget = mTabHost.getTabWidget();
// Como o TabWidget eh um ViewGroup, ele tem filhos e podemos iterar
// sobre os mesmos
int childCount = tabWidget.getChildCount();
for(int i = 0; i < childCount; ++i) {
View child = tabWidget.getChildTabViewAt(i);
// Que eh o mesmo que
//View child = tabWidget.getChildAt(i);
// Vide o codigo fonte
// O Drawable vai variar conforme o nome do seu tema, confirme se tem
// algum nome parecido com esse e altere aqui
child.setBackgroundResource(R.drawable.tab_indicator_ab);
}
Use this code at the end of the TabHost
setting.
The file tab_indicator_ab.xml
that is in the /res/drawable
directory is very similar to this:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@android:color/transparent" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_ab" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_ab" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_ab" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_ab" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_ab" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_ab" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_ab" />
</selector>