用户到达结束时如何实现 RecyclerView 项目拉伸效果?

问题描述

在现代 UI 中,当我们拉下回收视图的顶部时,它的孩子会被拉伸。这发生在用户手指施加的特定压力下。我附上了我从红米手机录制的这种效果的例子。如果我有 CardViews 作为我的 RecyclerView 的孩子,任何人都可以解释如何在 android studio 中实现这种类型(或者更好类型)的效果

RecyclerView stretch example

解决方法

在xml中使用swiperrefreshlayout

 <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/turnaments_list_recy_refresh_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="56dp"
    android:layout_marginBottom="?attr/actionBarSize"
    android:animateLayoutChanges="true"
    android:indeterminateTint="@color/blue_100_dark"
    app:layout_constraintBottom_toBottomOf="parent"

    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/turnaments_list_recy_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/image_help_buttom"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    </androidx.recyclerview.widget.RecyclerView>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

在 kotlin 代码中

    turnaments_list_recy_refresh_view.isRefreshing = false

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...