<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout\_width="0dp"
android:layout\_height="0dp"
app:layout\_constraintTop\_toTopOf="parent"
app:layout\_constraintEnd\_toEndOf="parent"
app:layout\_constraintStart\_toStartOf="parent"
app:layout\_constraintBottom\_toBottomOf="parent"
android:id="@+id/swipe\_refresh\_layout">
<androidx.recyclerview.widget.RecyclerView
android:layout\_width="match\_parent"
android:layout\_height="match\_parent" android:id="@+id/recycle\_view"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
使用比较简单 这里就模拟了一下加载效果 下拉触发加载显示动画此时isRefreshing=true 加载数据后需要修改为false 隐藏动画
swipe_refresh_layout.isRefreshing = false
swipe_refresh_layout.setOnRefreshListener {
Handler().postDelayed({
swipe_refresh_layout.isRefreshing = false
},2000)
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章