将折叠的工具栏逻辑实现到Recyclerview

时间:2019-11-03 17:17:20

标签: android view collapse

我有以下XML代码-

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Dummy Text"
        android:textSize="50sp" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/horizontalRecycler"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:listitem="@layout/row_item" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/verticalRecycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:listitem="@layout/row_item" />


</LinearLayout>

看起来像这样-

enter image description here

我想要实现的是折叠工具栏的相同功能,但带有我的recyclerview。 我希望水平recyclerview内的视图缩小到上限并稍微滚动一下,所有这些都是在向下滚动底部垂直布局时发生的。

如何实现这种行为?

我上传了一个gif来演示我想要实现的目标-

https://gph.is/g/4LggR0R

0 个答案:

没有答案
相关问题