Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable ScrollView scrolling?

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 ?

like image 785
filipp.kowalski Avatar asked Sep 06 '13 07:09

filipp.kowalski


1 Answers

// Get the ScrollView

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

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

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

// Enable Scrolling by removing the OnTouchListner

tvDisplayScroll.setOnTouchListener(null);    
like image 185
DrMartens Avatar answered Sep 19 '22 12:09

DrMartens