2014-06-16 59 views
1

我需要改变2个标签的尺寸在tabWidget但我想这一点:(Android)如何更改tabWidget中选项卡的大小?

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

但它没有工作。

这里是我的了:

TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); 

    TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); 
    TabSpec secondTabSpec = tabHost.newTabSpec("tid1"); 


    firstTabSpec.setIndicator("Calendrier").setContent(new Intent(this,PremiereTab.class)); 
    secondTabSpec.setIndicator("Convoiturage").setContent(new Intent(this,DeuxiemeTab.class)); 

    tabHost.addTab(firstTabSpec); 
    tabHost.addTab(secondTabSpec); 

我的XML文件:

<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:id="@+id/LinearLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

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

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

</LinearLayout> 
</TabHost> 

我搜索了很久都没有成功,帮助请!

回答

1

你可以改变乌尔XML:

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

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

我希望这将帮助你..

+0

任职的感谢! – Pleasure

+0

@PETEST欢迎DONT FORGET接受答案.. – prabhakaran

+0

正在搜索它,谢谢! – Pleasure

相关问题