I have been stuck on this issue for some days now. Can anyone help me customize the Tabs displayed below the ActionBar (NavigationMode is NAVIGATION_MODE_TABS
) ?
I'm not sure if you need this anymore but I will post the answer for other people to see. You can set this in the background Drawable
of the customActionBarTabStyle
as a Drawable resource:
<style name="customActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">@drawable/actionbar_tabs_selector</item>
<item name="android:textSize">12dp</item>
</style>
The resource should be a Selector, something among these lines:
<!-- This is the "@drawable/actionbar_tabs_selector" layout !-->
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_selected"/>
<!-- Pressed state -->
<item android:state_pressed="true" android:drawable="@drawable/actionbar_tab_style_selected" />
<!-- Focused state -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
</selector>
So the resources here are 2 Layer Lists. One for when the tab is inactive, and one for when the tab is selected and active. So you set 2 Layer Lists depending on the selected state.
A single Layer List may look like this:
<!-- This is the "@drawable/actionbar_tab_style_nselected" layout !-->
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Bottom Line -->
<item>
<shape android:shape="rectangle">
<solid android:color="@color/HCL_orange" />
</shape>
</item>
<!-- Tab color -->
<item android:bottom="2dip">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
Thus the first item is the bottom line that you could define as your underline color of the currently selected Tab, and the second item is the color of the whole tab.
You can use the available style generator, or get some more insight from this or this related question.