【问题标题】:ScrollListener for RecyclerView inside NestedScrollView?NestedScrollView 内 RecyclerView 的 ScrollListener?
【发布时间】:2017-05-28 10:36:34
【问题描述】:
我在NestedScrollView 中使用RecyclerView。平滑滚动
nestedScrollView.setNestedScrollingEnabled(true);
recyclerView.setNestedScrollingEnabled(false);
而且这个RecyclerView 是动态的,在scroll 上动态添加行。但是滚动监听器不起作用NestedScrollingEnabled 是假的。
【问题讨论】:
标签:
android
scroll
android-recyclerview
onscrolllistener
【解决方案1】:
scroller.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY > oldScrollY) {
Log.i(TAG, "Scroll DOWN");
}
if (scrollY < oldScrollY) {
Log.i(TAG, "Scroll UP");
}
if (scrollY == 0) {
Log.i(TAG, "TOP SCROLL");
}
if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
Log.i(TAG, "BOTTOM SCROLL");
f (viewGroup1.getChildAt(viewGroup1.getChildCount() - 1) instanceof RecyclerView){
//add code here }
}
}
});