Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoordinatorLayout leaves empty space at the bottom after scrolling

I am trying to implement Google's newest design tricks with CoordinatorLayout and have problems with scrolling and parallax effect.

After Activity is displayed, everything looks ok but the problem occurs when I try to scroll. It seems the bottom View is not expanded correctly and after it's scrolled up, empty space appears below. Bottom View seems to be big only how much it has on initial display between top View and nav bar.

It looks something like this:

enter image description here

Relevant code:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:expandedTitleMarginStart="72dp"
            app:expandedTitleMarginEnd="16dp">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax"/>
        </CollapsingToolbarLayout>
    </AppBarLayout>

    <ViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</CoordinatorLayout>
</FrameLayout>

This weird behavior happens randomly. Sometimes bottom View is scrollable normally and that empty space doesn't appear. What am I doing wrong? Thanks.

like image 928
user4386126 Avatar asked Sep 22 '15 21:09

user4386126


People also ask

Is CoordinatorLayout scrollable?

Android Layouts CoordinatorLayout Scrolling BehaviorAn enclosing CoordinatorLayout can be used to achieve Material Design Scrolling Effects when using inner layouts that support Nested Scrolling, such as NestedScrollView or RecyclerView .

What is Coordinator layout in android?

CoordinatorLayout is a super-powered FrameLayout . CoordinatorLayout is intended for two primary use cases: As a top-level application decor or chrome layout. As a container for a specific interaction with one or more child views.

How do I center in CoordinatorLayout?

Put the progress bar inside the CoordinatorLayout with android:layout_gravity="center" .


1 Answers

I had the same problem and I noticed that every layout with this problem had

android:fitsSystemWindows="true"

on CoordinatorLayout

Removing it fixed my problem everywhere.

like image 147
Apperside Avatar answered Nov 02 '22 01:11

Apperside