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透视脚本免费使用视频,hhpoker辅助软件下载,力荐教程(有挂透视);科技...
揭秘!hhpoker哪个俱乐部... 揭秘!hhpoker哪个俱乐部靠谱,uupoker有透视吗,系统教程(有挂方法)1、玩家可以在hhp...
热点推荐!拱趴游戏破解器,po... 热点推荐!拱趴游戏破解器,pokemmo脚本辅助,普及教程(有挂攻略)是由北京得拱趴游戏破解器黑科技...
一分钟秒懂!aapoker免费... 一分钟秒懂!aapoker免费透视脚本,大菠萝789辅助器下载,实用技巧(有挂技巧);玩家必备必赢加...
今日头条!wepoker挂,h... 今日头条!wepoker挂,hhpoker底牌透视脚本,细节方法(有挂方法);玩家必备必赢加哟《13...
玩家交流!werplan透视挂... 玩家交流!werplan透视挂,werplan外挂,微扑克教程(有挂辅助);小薇(透视辅助)致您一封...
揭秘!wepoker怎么增加运... 揭秘!wepoker怎么增加运气,epoker底牌透视,揭秘教程(有挂神器);建议优先通过wepok...
今日百科!约局吧开挂,hhpo... 《今日百科!约局吧开挂,hhpoker辅助,扑克教程(有挂方法)》 约局吧开挂软件透明挂更新公告新增...
玩家实测!wepoker私人局... 玩家实测!wepoker私人局透视,hhpoker有后台操控吗,AI教程(有挂教程);hhpoker...
科技新动态!hhpoker真能... 科技新动态!hhpoker真能买到挂吗,wepoker正确养号方法,曝光教程(有挂透明);hhpok...