Android回到顶部,并下拉刷新

ViewGroup.LayoutParams layoutParams = appBarLayout.getLayoutParams();
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
if (behavior != null) {
behavior.setTopAndBottomOffset(0);
}
((NestedScrollView)view.findViewById(R.id.scroll)).smoothScrollTo(0, 0);
refreshLayout.autoRefresh();
我使用的是CoordinatorLayout+SmartRefreshLayout库+NestedScrollView+RecyclerView
如果不使用NestedScrollView的话
recyclerView.scrollToPosition(0);

refreshLayout.autoRefresh();

参考:https://www.jianshu.com/p/5bee4447a7ac

posted @ 2024-08-22 11:27  only_books  阅读(14)  评论(0编辑  收藏  举报