Android Studio - 如何停止ScrollView回到顶部
创始人
2024-08-16 01:30:15
0

要停止ScrollView回到顶部,可以使用以下代码示例中的方法:

  1. 在XML布局文件中,将ScrollView替换为自定义的ScrollView子类,例如NoScrollScrollView:


    


  1. 创建NoScrollScrollView类,并继承自ScrollView:
public class NoScrollScrollView extends ScrollView {

    public NoScrollScrollView(Context context) {
        super(context);
    }

    public NoScrollScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoScrollScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }
}
  1. 通过将onTouchEvent和onInterceptTouchEvent方法的返回值设置为false,禁用ScrollView的滚动功能。

这样,当ScrollView被滚动时,它将不会回到顶部。

相关内容

热门资讯

一分钟揭秘!wepoker有辅... 一分钟揭秘!wepoker有辅助插件吗,wepoker辅助器最新版本更新内容,安装教程(有挂技巧);...
透视黑科技"clou... 这是一款非常优秀的cloudpoker外挂 ia辅助检测软件,能够让你了解到cloudpoker外挂...
透视软件!红龙poker透视工... 透视软件!红龙poker透视工具,we-poker靠谱吗,可靠技巧(有挂解说)亲,关键说明,红龙po...
透视真的"wpk透视... 透视真的"wpk透视工作室"详细辅助辅助教程(透视脚本下载技巧);支持多人共享记分板与复盘,通过邀请...
透视真的!hhpoker透视脚... 透视真的!hhpoker透视脚本,悦扑克脚本,必赢方法(有挂技巧);1、不需要AI权限,帮助你快速的...
透视黑科技"wepo... 透视黑科技"wepoker怎么看底牌"详细辅助透明挂教程(免费脚本方法)是一款可以让一直输的玩家,快...
透视了解!hhpoker辅助软... 透视了解!hhpoker辅助软件下载,约局吧德州可以透视吗,科技教程(有挂脚本)1、该软件可以轻松地...
透视有挂"菠萝德普辅... 透视有挂"菠萝德普辅助器免费版在哪里"详细辅助普及教程(透视脚本免费app技巧)1、点击下载安装,微...
透视实锤!德普之星透视辅助io... 透视实锤!德普之星透视辅助ios,aapoker怎么设置抽水,AI教程(有挂黑科技);1、进入到德普...
透视了解"wepok... 1、透视了解"wepoker养号规律"详细辅助解密教程(外挂教程)。2、wepoker养号规律透视辅...