Search code examples
androidandroid-style-tabhost

android tabhost custom color


I am using Tabhost for project Tabs. I changed the color of the tab to blue but there is 2px line bellow the tab. Can any one help me to change the white color to blue. http://img816.imageshack.us/img816/228/device.png


Solution

  • There's probably something wrong with your screen design not related to TabHost. Did you check the screen/widgets/layouts paddings?

    The following code snippet does exactly what you want. Add another Tab and that's it.

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:layout_alignParentBottom="true"/>
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_above="@android:id/tabs">
    
                <include android:id="@+id/tab1" layout="@layout/tab1" />
    
                <include android:id="@+id/tab2" layout="@layout/tab2" />
    
                <include android:id="@+id/tab3" layout="@layout/tab3" />
            </FrameLayout>
        </RelativeLayout>
    </TabHost>