FrameLayout doesn't fill CoordinatorLayout after GONE a view

1.3k views Asked by At

Here is my main layout :

<LinearLayout 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="fill_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">

<RelativeLayout
    android:id="@+id/top_con"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:background="#cc0000">

    <TextView
        android:id="@+id/close"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:clickable="true"
        android:text="Close"
        android:textColor="#ffffff" />
</RelativeLayout>

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/blue"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/green"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


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

After event onClick on TextView (id/close), I set visibility for RelativeLayout (id/top_con) to GONE. But FrameLayout (contain a recycler view) still keep their height, and there's a white space (white is background color of CoordinatorLayout ) at bottom of sreen. What is problem and how can fix it? Thank you!

0

There are 0 answers