gpt4 book ai didi

android - 如何检测Android Scroll View是否处于空闲状态?

转载 作者:行者123 更新时间:2023-12-04 23:56:44 25 4
gpt4 key购买 nike

我试图在 ScrollView 处于空闲状态时隐藏一个按钮。按钮应该只在滚动期间不可见。(其余时间按钮应该可见)

scrollView.setOnScrollChangeListener(new ScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollX == scrollY) {
Button.setVisibility(View.VISIBLE);
} else if ((scrollY > oldScrollY)) {
Button.setVisibility(View.INVISIBLE);
}
}
});

最佳答案

找到解决方案

    scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch( View v, MotionEvent event ) {
switch ( event.getAction( ) ) {
case MotionEvent.ACTION_SCROLL:
case MotionEvent.ACTION_MOVE:
Log.e( "SCROLL", "ACTION_SCROLL" );
break;
case MotionEvent.ACTION_DOWN:
Log.e( "SCROLL", "ACTION_DOWN" );
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
Log.e( "SCROLL", "SCROLL_STOP" );
break;
}
return false;
}
});

关于android - 如何检测Android Scroll View是否处于空闲状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47008608/

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