Search code examples
androidandroid-tabhost

how to set title and height to tab host in android?


I have a question that I am implementing a tab in my android app but Tab host not displays title.

I use the following code in XML

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="63dip"/>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>

Please tell how to display title and set the size to tab host in android


Solution

  • I recommend you look here.

    Basically, you create a custom layout(This is all from that link BTW):

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient android:startColor="#A8A8A8" android:centerColor="#7F7F7F"
            android:endColor="#696969" android:angle="-90" />
    </shape>
    

    Then you inflate it. Since I don't want to do straight-up plagiarism, just check the link.