Android自动隐藏功能会干扰我的TabHost

时间:2014-03-05 18:04:11

标签: android android-tabhost

我在Android 4.x上使用TabHost测试应用程序。它工作正常,除了TABS隐藏在标题之后(应该自动隐藏)。 如果我启用自动隐藏它也不好,因为即使我看到标题隐藏并且TABS可以直接访问...如果我尝试单击TAB,则标题栏会与TABS重叠并阻止我单击在我的TAB上。

我该怎么办? 这是我的布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0099cc"
    tools:context="ro.whatever.myapp.testtabhost.app.main">


    <TabHost
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@android:id/tabhost"
        android:layout_gravity="center_horizontal|top">

        <LinearLayout
            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">

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</FrameLayout>

所以在我为这个布局创建活动之后......我无法点击我在屏幕顶部看到的TABS,因为titl-bar下降并点击其自身......

这很烦人。 怎么解决这个问题?

1 个答案:

答案 0 :(得分:0)

我在活动的onCreate中执行此操作解决了这个问题:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); // this thing hides the title bar so I can access the TabHost
    setContentView(R.layout.activity_main);

可能涉及的人;)

相关问题