如何阻止我的TabLayout剥离我的其他视图

时间:2017-05-19 09:12:34

标签: android android-layout android-xml android-tablayout

http://imgur.com/Gx7nFdQ

如何阻止这种情况发生?我在标签布局上有一个视图寻呼机,基本上我正在使用一个片段(请查看上面附带的图像链接)

  

<RelativeLayout
    android:id="@+id/root1"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >



    <android.support.v4.view.ViewPager
        android:id="@+id/simpleViewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/toolbar"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        app:tabMode="fixed"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:elevation="6dp"
        app:tabTextColor="@android:color/darker_gray"
        app:tabBackground="@android:color/white"
        app:tabSelectedTextColor="#ff00ff"
        app:tabIndicatorColor="#ff00ff"
        android:minHeight="?attr/actionBarSize"
        android:layout_alignParentBottom="true"
        />

</RelativeLayout>

我应该使用NestedScrollView而不是相对布局,这会有帮助吗?

任何帮助都将深表感谢

2 个答案:

答案 0 :(得分:1)

android:layout_above="@+id/tabLayout"上添加ViewPager,然后从+的ID声明中删除tabLayoutandroid:id="@id/tabLayout"

答案 1 :(得分:0)

<android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_below="@+id/simpleViewPager"
        app:tabMode="fixed"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:elevation="6dp"
        app:tabTextColor="@android:color/darker_gray"
        app:tabBackground="@android:color/white"
        app:tabSelectedTextColor="#ff00ff"
        app:tabIndicatorColor="#ff00ff"
        android:minHeight="?attr/actionBarSize"
        android:layout_alignParentBottom="true"
        />
相关问题