//滑动到评论界面 AppBarLayout mAppBarLayout=getView(R.id.app_bar); CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).getBehavior(); if (behavior instanceof AppBarLayout.Behavior) { int screenHeight = ScreenUtil.getScreenHeight(PostDetailActivity.this); AppBarLayout.Behavior appBarLayoutBehavior = (AppBarLayout.Behavior) behavior; int topAndBottomOffset = appBarLayoutBehavior.getTopAndBottomOffset(); RelativeLayout mComentLayout = getView(R.id.layout_comment); appBarLayoutBehavior.setTopAndBottomOffset(-mLayoutTab.getTop());//这里执行滑动,负数代表向下滚动 LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); int index= manager.findFirstCompletelyVisibleItemPosition();//第一个完整可见得item if (index>0) { mRecyclerView.smoothScrollToPosition(0); } 方法作用 LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();findFirstVisibleItemPosition() 返回当前RecycelrView中第一个可见的item的adapter postionfindLastVisibleItemPosition()返回当前RecycelrView中最后一个可见的item的adapter postion
findFirstCompletelyVisibleItemPosition()返回当前RecycelrView中第一个完整可见的item的adapter postion
findLastCompletelyVisibleItemPosition()返回当前RecycelrView中最后一个完整可见的item的adapter postion
}
CollapsingToolbarLayout滑动状态监听
https://www.jianshu.com/p/d328a26ecfa0