I try to migrate my existing code from TabActivity to FragmentActivity because TabActivity is now deprecated.
Until here, i used this code to change the background color of each tab :
TabWidget widget = tabHost.getTabWidget();
for(int i = 0; i < widget.getChildCount(); i++) {
View v = widget.getChildAt(i);
// Look for the title view to ensure this is an indicator and not a divider.
TextView tv = (TextView)v.findViewById(android.R.id.title);
tv.setTextColor(Color.parseColor("#E64260"));
tv.setTextSize(15);
tv.setTypeface(robotolight);
v.setBackgroundResource(R.drawable.tab_selector);
}
tab_selector.xml :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:drawable="@drawable/tab_unselected_example" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/tab_selected_example" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<!-- Focused states -->
<item android:drawable="@drawable/tab_unselected_focused_example" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/tab_selected_focused_example" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/tab_unselected_pressed_example" android:state_focused="false" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@drawable/tab_selected_pressed_example" android:state_focused="false" android:state_pressed="true" android:state_selected="true"/>
<!-- Focused states -->
<item android:drawable="@drawable/tab_unselected_pressed_example" android:state_focused="true" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@drawable/tab_selected_pressed_example" android:state_focused="true" android:state_pressed="true" android:state_selected="true"/>
</selector>
I don't know how to adapt this code for Fragment Activity. Could you help me ?
UPDATE :
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="Theme.Detail_bar_style" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_detail_bar_style</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Detail_bar_style</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Detail_bar_style</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Detail_bar_style</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Detail_bar_style</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Detail_bar_style</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_detail_bar_style</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_detail_bar_style</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Detail_bar_style</item>
</style>
<style name="ActionBar.Solid.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_background_textured_detail_bar_style</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_detail_bar_style</item>
<item name="android:backgroundSplit">@drawable/ab_background_textured_detail_bar_style</item>
<item name="android:progressBarStyle">@style/ProgressBar.Detail_bar_style</item>
</style>
<style name="ActionBar.Transparent.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/ab_transparent_detail_bar_style</item>
<item name="android:progressBarStyle">@style/ProgressBar.Detail_bar_style</item>
</style>
<style name="PopupMenu.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_detail_bar_style</item>
</style>
<style name="DropDownListView.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_detail_bar_style</item>
</style>
<style name="ActionBarTabStyle.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_detail_bar_style</item>
</style>
<style name="DropDownNav.Detail_bar_style" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_background_ab_detail_bar_style</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_detail_bar_style</item>
<item name="android:dropDownSelector">@drawable/selectable_background_detail_bar_style</item>
</style>
<style name="ProgressBar.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_detail_bar_style</item>
</style>
<style name="ActionButton.CloseMode.Detail_bar_style" parent="@android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_detail_bar_style</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Detail_bar_style.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Detail_bar_style</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Detail_bar_style</item>
</style>
</resources>