Android how to make recyclerview overscroll bounce affect when out of bounds?

I am looking for a way to make my recycleView elastic at the top when pulled. Let me show you an image of what I want:

https://raw.githubusercontent.com/baoyongzhang/android-PullRefreshLayout/master/demo.gif

So you can see from this gif that when the user rolls off the top of the list, it has a bouncy bounce effect. How can I achieve this? I want this to be affected, so my swipeRefreshLayout doesn't get triggered so easily, just reaching the top. i want them to actually PULL to freshen up not only to the top. my app bar layout looks like this:

    <?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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:fitsSystemWindows="false"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/id_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="@color/white"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:titleEnabled="false">

            <com.mobile..UI.customViews.CategoryBanner
                android:id="@+id/shortcutbanner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax" />

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


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

        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill"
            app:tabMode="fixed"
            android:elevation="6dp"
            app:tabSelectedTextColor="@android:color/darker_gray"
            app:tabTextColor="@color/black" />

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


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

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



            <com.mobile.UI.customViews.HomePageViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="fill_vertical"
                />


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

      

and inside the tab I have the following recyclerView:

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


    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipefeedRefreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <com.mobile.UI.customViews.VelocityControlRecyclerView
        android:id="@+id/recyclerView"
        android:layout_marginTop="0dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

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

      

in my activity i tried calling this but it doesn't work:

mRecyclerView.setOverScrollMode(View.OVER_SCROLL_ALWAYS);

      

+3


source to share





All Articles