Ryada
Ryada

Reputation: 95

how to change the tab widget size in TabHost

In my application i use the tabhost in linear layout, tabhost contains 4 tabs. The size of the tabwidget is very very high and it shows title very small. Can any one help me how to reduce the size of tabwidget.

Upvotes: 0

Views: 7354

Answers (2)

Barak
Barak

Reputation: 16393

I'm not clear on exactly what you're looking to do here, but I'll make a guess at it.

If you don't want space to be taken up by graphics (in other words, have text only) you can set the height and graviy of the widget to effectively remove the space that is used by the graphic, making for a much more compact tab label (vertically).

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:gravity="bottom" />

Upvotes: 0

Lalit Poptani
Lalit Poptani

Reputation: 67296

I would insist to create custom Tabs using setIndicator(View). So, create a TextView of your desired size and set it to the TabWidget. Here is an Tutorial for the same with Example.

You can just inflate a TextView and set it to the TabWidget using

View view = LayoutInflater.from(context).inflate(R.layout.your_custom_tab-layout,
                                                                           null);
TextView tv = (TextView) view.findViewById(R.id.my_text_view);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tv).
                                                              setContent(intent);
mTabHost.addTab(setContent);

Upvotes: 4

Related Questions