gpt4 book ai didi

java - 我想检测滚动事件的结束

转载 作者:行者123 更新时间:2023-12-02 00:32:53 27 4
gpt4 key购买 nike

我想检测scrollView的滚动事件结束。首先,我实现 OnCrollChange 方法,并尝试监听一些值,如果它们可以帮助我知道滚动的结束。谢谢你帮助我。

 scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener(){
@Override
public void onScrollChange(View view, int i, int i1, int i2, int i3){
Toast.makeText(getApplicationContext(),"in SCroll ------->"+i+" "+i1+" "+i2+" "+i3,Toast.LENGTH_SHORT).show();
shadowView.setBackgroundResource(R.drawable.shadow);
if ((i3==0)){
Toast.makeText(getApplicationContext()," equality ----------------------> ",Toast.LENGTH_SHORT).show();
shadowView.setBackgroundResource(R.drawable.trans);
}
else {
// Toast.makeText(getApplicationContext()," NO ----------------------> ",Toast.LENGTH_SHORT).show();
}
}

});

最佳答案

这会有所帮助

scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
if (scrollView != null) {
if (scrollView.getChildAt(0).getBottom() <= (scrollView.getHeight() + scrollView.getScrollY())) {
//scroll view is at bottom
} else {
//scroll view is not at bottom
}
}
}
});

关于java - 我想检测滚动事件的结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51686829/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com