如何禁用滚动型滚动? [英] How to disable ScrollView scrolling?

查看:142
本文介绍了如何禁用滚动型滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图解决这个问题:<一href="http://stackoverflow.com/questions/18639668/how-to-disable-pulltorefreshscrollview-from-listening-to-touch">How从听触摸我不知道它有一个解决方案,以阻止从处理onTouchEvents滚动型没有为它创建自定义的类禁用pullToRefreshScrollView? 为什么像所有的methos

Trying to resolve this issue : How to disable pullToRefreshScrollView from listening to touch I am wondering it there is a solution, to block ScrollView from handling onTouchEvents without creating customizable class for it ? Why all the methos like

gridView.getParent().requestDisallowInterceptTouchEvent(true);

mScrollView.setOnTouchListener(new OnTouchListener() {
           @Override
           public boolean onTouch(View v, MotionEvent event) {
              return false;
           }
        });

不工作?什么是他们的问题?为什么谷歌实现方法不工作?

doesn't work ? what's the problem with them ? why Google implements methods which doesn't work ?

推荐答案

//获取滚动型

final ScrollView myScroll = (ScrollView) findViewById(R.id.display_scrollview);

//禁用滚动通过建立一个OnTouchListener做什么

// Disable Scrolling by setting up an OnTouchListener to do nothing

myScroll.setOnTouchListener( new OnTouchListener(){ 
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true; 
    }
});

//启用滚动通过删除OnTouchListner

// Enable Scrolling by removing the OnTouchListner

tvDisplayScroll.setOnTouchListener(null);    

这篇关于如何禁用滚动型滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆