2014-06-16 75 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

相關問題