Monday, February 25, 2013

ScrollView Inside ScrollView in Android


 mParentScroll = (ScrollView) findViewById( R.id.parentScrollView );
 mChildScroll = (ScrollView) findViewById( R.id.childScrollView );

use touch listener to enable/disable Scroll


 mParentScroll.setOnTouchListener( new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                // Log.v(TAG,”PARENT TOUCH”);
                mChildScroll.getParent().requestDisallowInterceptTouchEvent(
                        false );
           
                return false;
            }
        } );
        mChildScroll.setOnTouchListener( new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                // Log.v(TAG,”CHILD TOUCH”);
                // Disallow the touch request for parent scroll on touch of
                // child view
                v.getParent().requestDisallowInterceptTouchEvent( true );
             
                return false;
            }
        } );

No comments:

Post a Comment

Give your comment here...