在您向上滑动时向上滑动RecyclerView,或在向下滑动时向下滑动Recyclerview

And*_*oid 17 android sliding android-recyclerview

我想创建一个Fragment带有RecyclerView滑动的项目,并在向上滑动时显示更多项目.

这是我正在谈论的一个例子.

初始创作:

在此输入图像描述

用户向上滑动RecyclerView向上滑动,显示更多项目:

在此输入图像描述

有几个问题,我想不使用一个CoordinatorLayout,我想把它设置到RecyclerView堆叠中的项目直接在上面EditText.

这是我使用的布局代码:

<android.support.design.widget.CoordinatorLayout
android:id="@+id/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:visibility="visible">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:background="@android:color/transparent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingToolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <View
            android:id="@+id/emptyView"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:background="@android:color/transparent"
            app:layout_collapseMode="parallax"/>

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

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

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

        <EditText
            android:id="@+id/editText"
            android:paddingLeft="16dp"
            android:inputType="textAutoCorrect"
            android:layout_centerVertical="true"
            android:background="@android:color/transparent"
            android:layout_width="match_parent"
            android:layout_height="56dp"/>

    </RelativeLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我得到这样的东西:

在此输入图像描述

这绝对不可扩展,需要持续测量空视图.

And*_*oid 11

我通过使用自定义解决了这一问题,TouchListener所有其他解决方案都是非常基本的,仅限于特定的盒装用例.

我这样做的方式是实现一个新的TouchListener基于这个库:

BounceTouchListener

我得到以下结果:

在此输入图像描述


Dav*_*vid 5

RecyclerView与 2 种类型的行一起使用:

  1. 空行/灰色行(无分隔线)
  2. 包含您已有内容的行

必须RecyclerView将 match_parent 匹配到整个片段

因此,您将获得顶部“空白”区域的正确效果RecyclerView

在此输入图像描述