查看底部标签布局的寻呼机不起作用?

时间:2016-09-06 07:38:47

标签: android

我想在底部使用标签栏... 这是我的Xml文件...... 它显示在底部但在viewpager的片段上重叠

<?xml version="1.0" encoding="utf-8"?>

<include layout="@layout/app_bar" />

<RelativeLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorMiddarkGray"
        app:tabBackground="@drawable/tab_color_selector" />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_above="@id/sliding_tabs"
        android:layout_alignParentTop="true" />

</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:itemBackground="@color/colorMiddarkGray">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include
            android:id="@+id/nav_view_header"
            layout="@layout/nav_header_main" />

        <include layout="@layout/nav_menu" />
    </LinearLayout>
</android.support.design.widget.NavigationView>

但输出不完全显示.. 我的viewpager没有得到底部填充或边距... 我想用视图寻呼机显示底部标签布局

enter image description here

1 个答案:

答案 0 :(得分:1)

我将RelativeLayout更改为LinearLayout,因为layout_weight仅适用于LinearLayout个孩子,然后将订单更改为显示ViewPager,然后显示TabLayout 。试试这个:

<LinearLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_above="@id/sliding_tabs"
        android:layout_alignParentTop="true" />

    <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorMiddarkGray"
        app:tabBackground="@drawable/tab_color_selector" />



</LinearLayout>