监听ScrollView上下滑动

西门飞翮
2023-12-01
 mScrollView.setScrollViewListener(new ScrollViewListener() {
            @Override
            public void onScrollChanged(MyScrollview scrollView, int l, int t, int oldl, int oldt) {
                if (oldt < t && ((t - oldt) > 15)) {// 向上
             Log.e("wangly", "距离:"+(oldt < t) +"---"+(t - oldt));
             Log.e("TAG","向上滑动");
             
                } else if (oldt > t && (oldt - t) > 15) {// 向下
              Log.e("wangly", "距离:"+(oldt > t) +"---"+(oldt - t));
              Log.e("TAG"," 向下滑动");
             
                }
            }

        });

 类似资料: