1

When using CoordinateLayout, I am facing a pretty strange behaviour that I guess it is a default implementation.

I have an activity that has a layout as below:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways">

            // the header layout here
        </android.support.v7.widget.Toolbar>

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

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

    </android.support.v4.view.ViewPager>

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

The pager has some fragments which has the UI looks like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

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

        </RecyclerView>

    </android.support.v4.widget.SwipeRefreshLayout>

    <View
         android:id="@+id/bottom_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>

</FrameLayout>

I want the bottom_view to pin to the bottom of the layout but as soon as the recycler view scrolls, the bottom_view scroll as well. There is nothing special about the layout as well as the code. Is this behaviour is default or I miss something?

I have tried to wrap the bottom view by a collapse toolbar and set it to "pin" mode but it does not help.

Paul
  • 950
  • 2
  • 12
  • 28
  • Possible duplicate of [Android - footer scrolls off screen when used in CoordinatorLayout](http://stackoverflow.com/questions/30777698/android-footer-scrolls-off-screen-when-used-in-coordinatorlayout) – marmor Oct 30 '16 at 11:24
  • Thanks but it is too complicated for this. I am looking for a more simpler way or I have to change the layout. – Paul Oct 30 '16 at 13:16
  • 1
    I couldn't find another way of anchoring views, a bug that was opened on this was rejected as being "by design": https://code.google.com/p/android/issues/detail?id=177195 – marmor Oct 30 '16 at 14:10

0 Answers0