工具栏重叠相对布局

时间:2018-01-07 19:50:51

标签: android toolbar

我的xml文件有问题。工具栏位于相对布局上方。我试过像fitSystemWindows和其他一些属性,但我无法解决它。有什么想法可以解决哪个属性可以修复它?

This is my design

所以,这是我的xml文件。我尝试添加到relavite布局中的fitsSystemWindows属性但是还没有工作

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:fitsSystemWindows="false"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_main"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_collapseMode="pin">

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

</android.support.design.widget.AppBarLayout>

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

    <RelativeLayout
        android:id="@+id/layout_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="wrap_content"
            android:indeterminateOnly="true"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true" />
    </RelativeLayout>

    <com.theapplabperu.queestudiar.Utils.EmptyRecyclerView
        android:layout_width="match_parent"
        android:id="@+id/rv_universities"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <LinearLayout
        android:id="@+id/empty_main"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent"
        android:layout_gravity="center">

        <LinearLayout
            android:layout_width="match_parent"
            android:gravity="center_vertical"
            android:layout_marginRight="24dp"
            android:layout_marginLeft="24dp"
            android:orientation="vertical"
            android:layout_height="match_parent">
            <ImageView
                android:src="@drawable/ic_intro_brain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/txt_empty_title"
                android:layout_margin="12dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:textSize="24sp"
                android:textStyle="bold"
                android:text="Ups!"/>
            <TextView
                android:id="@+id/txt_empty_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:textSize="14sp"
                android:text="No hay resultados para mostrar."/>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

只需将app:layout_behavior="@string/appbar_scrolling_view_behavior"添加到RelativeLayout即可。这应该将该布局放在appbar下