Is it possible to set the TabWidget height and have the tab labels adjust?
If I set the TabWidget height too small, then the labels are hidden from view.
<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">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="30px" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp" />
    </LinearLayout>
</TabHost>
Thanks
The following code adjusts the height on the tabs:
for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) {
    tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 33;
}  
However, this will create a defect on the background color of the un-selected tab. I don'n know how to solve this yet. Some forums suggest it is not solvable without making a custom tab widget.
Android 1.6 added a setIndicator() method on TabSpec that accepts a View. I have not tried it yet, but my understanding is that it will give you greater control over the tabs.
i see... when u addTab, usually we use setIndicator like this:
QTabHost.addTab(QTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").bla bla....
u can use TextView to replace "TAB 2", became like this:
tview=new TextView(this); tview.setText("Title here"); QTabHost.addTab(QTabHost.newTabSpec("tab_test2").setIndicator(tview).bla bla....
all u need is just modify the textview. Thanks... ^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With