以下是我的tabhost。
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:padding="0px"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:background="@drawable/mbg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</FrameLayout>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<TabWidget
android:id="@android:id/tabs"
android:padding="0px"
android:dividerPadding="0px"
android:showDividers="none"
android:layout_margin="0px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</LinearLayout>
</TabHost>
以下是我的测试标签
public class tabtest extends TabActivity {
private TabHost tabHost;
private TabWidget tabWidget;
Field mBottomLeftStrip;
Field mBottomRightStrip;
public Context thisContext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.PROGRESS_INDETERMINATE_OFF);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.tabgroup);
makeTab();
}
public void makeTab(){
if(this.tabHost == null){
tabHost = getTabHost();
tabWidget = getTabWidget();
tabHost.setup();
tabHost.bringToFront();
TabSpec tab1 = tabHost.newTabSpec("Tab1");
TabSpec tab2 = tabHost.newTabSpec("Tab2");
TabSpec tab3 = tabHost.newTabSpec("Tab3");
TabSpec tab4 = tabHost.newTabSpec("Tab4");
TabSpec tab5 = tabHost.newTabSpec("Tab5");
TabSpec tab6 = tabHost.newTabSpec("Tab6");
tab1.setIndicator("Tab1",getResources().getDrawable(R.drawable.first)).setContent(new Intent(this,IntentGroup1.class));
tab2.setIndicator("Tab2",getResources().getDrawable(R.drawable.second)).setContent(new Intent(this,IntentGroup1.class));
tab3.setIndicator("Tab3",getResources().getDrawable(R.drawable.third)).setContent(new Intent(this,IntentGroup1.class));
tab4.setIndicator("Tab4",getResources().getDrawable(R.drawable.first)).setContent(new Intent(this,IntentGroup1.class));
tab5.setIndicator("Tab5",getResources().getDrawable(R.drawable.second)).setContent(new Intent(this,IntentGroup1.class));
tab6.setIndicator("Tab6",getResources().getDrawable(R.drawable.third)).setContent(new Intent(this,IntentGroup1.class));
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.addTab(tab3);
tabHost.addTab(tab4);
tabHost.addTab(tab5);
tabHost.addTab(tab6);
}
}
}
以下是Intent的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
以下是IntentGroup1.class
public class IntentGroup1 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ilayout1);
}
第一次,它可以正常显示。但如果手机改为待机模式并再次唤醒,则Tab只显示一半左右。任何人都可以帮忙吗?