0
我想在HoneyComb上創建一個TabHost,就好像我在1.6+上一樣,但事實是當我複製代碼時(這與HoneyComb和之前的版本相同版本),TabHost與屏幕寬度不匹配。我不明白嗎?TabHost不匹配是HoneyComb中的父寬度Android 3.0
在模擬器上使用API 3.0上的光暈主題。
這裏的XML:
<?xml version="1.0" encoding="utf-8"?>
<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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</TabHost>
這裏是我的活動:
package org.agetac;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
public class TabsActivity extends TabActivity {
private static final String TAB_SITAC = "tab_sitac";
private static final String TAB_SOEI = "tab_soei";
private static final String TAB_MOYEN = "tab_moyen";
private static final String TAB_TAB4 = "tab_tab4";
private static final String TAB_TAB5 = "tab_tab5";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
TabHost tHost = getTabHost();
TabHost.TabSpec spec;
Intent tabIntent;
// Initialize a TabSpec for each tab and add it to the TabHost
tabIntent = new Intent().setClass(this, SITACActivity.class);
spec = tHost.newTabSpec(TAB_SITAC).setIndicator(getString(R.string.sitac),
getResources().getDrawable(R.drawable.ic_tab_sitac))
.setContent(tabIntent);
tHost.addTab(spec);
tabIntent = new Intent().setClass(this, SOEIActivity.class);
spec = tHost.newTabSpec(TAB_SOEI).setIndicator(getString(R.string.soei),
getResources().getDrawable(R.drawable.ic_tab_soei))
.setContent(tabIntent);
tHost.addTab(spec);
tabIntent = new Intent().setClass(this, MoyenActivity.class);
spec = tHost.newTabSpec(TAB_MOYEN).setIndicator(getString(R.string.moyen),
getResources().getDrawable(R.drawable.ic_tab_moyen))
.setContent(tabIntent);
tHost.addTab(spec);
tabIntent = new Intent().setClass(this, Tab4Activity.class);
spec = tHost.newTabSpec(TAB_TAB4).setIndicator(getString(R.string.tab4),
getResources().getDrawable(R.drawable.ic_tab_tab4))
.setContent(tabIntent);
tHost.addTab(spec);
tabIntent = new Intent().setClass(this, Tab5Activity.class);
spec = tHost.newTabSpec(TAB_TAB5).setIndicator(getString(R.string.tab5),
getResources().getDrawable(R.drawable.ic_tab_tab5))
.setContent(tabIntent);
tHost.addTab(spec);
tHost.setCurrentTab(0);
}
}
有誰知道爲什麼TabHost行爲那樣與蜂窩?
這就是我在平板電腦上的模擬器 [截圖](http://imageshack.us/photo/my-images/849/capturedu20111117135437.png) – Leiko