Android 将ViewPager选项卡与RelativeLayout重叠

Android 将ViewPager选项卡与RelativeLayout重叠,android,android-layout,android-actionbar,android-viewpager,android-relativelayout,Android,Android Layout,Android Actionbar,Android Viewpager,Android Relativelayout,我有一个活动,它包含一个带有两个选项卡的ViewPager。当用户按下按钮时,我希望出现一个不透明的RelativeLayout覆盖,用户可以在其中选择不同的选项 问题是,覆盖层没有覆盖ViewPager的选项卡,而是短时间停止 我的XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" androi

我有一个活动,它包含一个带有两个选项卡的ViewPager。当用户按下按钮时,我希望出现一个不透明的RelativeLayout覆盖,用户可以在其中选择不同的选项

问题是,覆盖层没有覆盖ViewPager的选项卡,而是短时间停止

我的XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true"
            android:background="@color/light_gray" >

            <TextView
                 ..../>

        </LinearLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/footer"/>

    </RelativeLayout>

    <Button
        .../>

    <RelativeLayout
        android:id="@+id/overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/orange"
        android:visibility="gone"
        android:alpha="0.9">
    </RelativeLayout>

</RelativeLayout>

它现在看起来是什么样子:

我希望它看起来像什么:


如果选项卡属于操作栏,则不能仅覆盖选项卡。 但是,如果使用支持库v7,则可以在布局文件中定义工具栏(ActionBar的新名称)。 您还可以在xml中定义TabLayout(选项卡的容器)。 要做到这一点,你必须使用谷歌新的设计支持库

只需通过添加

    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
到你的gradle档案。现在你可以使用

    <android.support.v7.widget.Toolbar />
    <android.support.design.widget.TabLayout />

非常感谢,这正是我需要的!
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.TabLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent" />

        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </RelativeLayout>

</LinearLayout>