TabActivity选项卡未显示在前面

时间:2015-06-07 13:16:25

标签: android

我的标签布局有问题。当我启动TabActivity时,选项卡显示在背景中而不是顶部。为什么会这样?

TabsActivity:

public class TabSample extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabactivity);
        TabHost tabHost = getTabHost();       

        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("ABC").setContent(new Intent(this, SettingsActivity.class)));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("DEF").setContent(new Intent(this, Support.class)));
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("GHI").setContent(new Intent(this, EmailActivity.class)));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("TV Survey").setContent(new Intent(this, JKL.class)));

        tabHost.setCurrentTab(0);
    }
}

tabsactivity.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">
    <RelativeLayout
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_alignParentBottom="true"
            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" />
    </RelativeLayout>
</TabHost>

1 个答案:

答案 0 :(得分:0)

对frameLayout

使用layout_above =“id / tabs”