TheDevMan
TheDevMan

Reputation: 5954

How to resize the height in Tabhost in android

I would like to resize the tabhost in android. I know it is deprecated, but this has been wonderful option for me because I am using ListActivity with custom cursor Adaptor. I am not if this posible with Fragment Tabhost.

Anyways to resize the tab height:

I tried the following:

for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) 
{
  tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 80;
 }  

It worked in few phones only. Is there any other way to solve this issue?

Thanks!

Upvotes: 1

Views: 4467

Answers (2)

Mehul Joisar
Mehul Joisar

Reputation: 15358

Right now, you are setting it in pixels, you should use dp,

try to replace

tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 80;

with

tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = (int) (80 * this.getResources().getDisplayMetrics().density);

Upvotes: 6

Tssomas
Tssomas

Reputation: 362

Change the height of the tabwidget in the xml file.

<TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="30dp">

        </TabWidget>

Change the height to whatever? That worked for me, if that is what you were looking for.

Upvotes: 0

Related Questions