【发布时间】:2014-06-16 09:44:21
【问题描述】:
我需要更改 tabWidget 中 2 个选项卡的大小,但我试过了:
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>
我找了半天没有成功,请大家帮忙!
【问题讨论】:
标签: android xml eclipse android-tabhost tabwidget