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