First create the xml file bottom_tabs.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF" >
<RelativeLayout
android:id="@+id/linearLayoutTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0" />
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#00000000"
android:tabStripEnabled="true" />
</RelativeLayout>
</android.support.v4.app.FragmentTabHost>
Add a background image to the tab icon, for example:
mTabHost.getTabWidget().getChildAt(0)
.setBackgroundResource(R.drawable.d_tab_bg_selector);
d_tab_bg_selector code:
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/d_pressed_state" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<item android:drawable="@drawable/d_unpressed_state" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/d_pressed_state" android:state_pressed="true"/>
<item android:drawable="@drawable/d_unpressed_state" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
d_pressed_state source code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#00000000" />
</shape>
</item>
<item
android:top="8dp">
<shape android:shape="rectangle">
<solid android:color="#009343" />
</shape>
</item>
<item android:right="1dp" android:left="1dp">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
Write your own code for your unspecified state.
source
share