12

I doing this In Android 1.6 and 2.2 ...

I have One ScrollView in the Activity (All the content in the ScrollView) ...

And Second is, One ListView in the Activity ....

When I Scroll ListView, at that time ScrollView is scrolling but ListView's Scroll is not working ...

I provide the scatch of the problem which I have ...

If anyone have solution of this, then please share ...

enter image description here

Darshak
  • 2,298
  • 4
  • 23
  • 45
  • Romain Guy (Android engineer) [suggested](http://stackoverflow.com/a/3496042/1521536) that you should ***not*** use a scrollable view inside a `ScrollView`. This question seems to be a duplicate of that answer's question too. –  Feb 25 '13 at 08:00
  • possible duplicate of [How can I put a ListView into a ScrollView without it collapsing?](http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing) – Ian Roberts Feb 28 '13 at 11:58

1 Answers1

33

here parentScroll = your main scrollview and childScroll = your listview

parentScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("PARENT", "PARENT TOUCH");
                    findViewById(R.id.child_scroll).getParent()
                            .requestDisallowInterceptTouchEvent(false);
                    return false;
                }
            });

  childScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("CHILD", "CHILD TOUCH");
                    // Disallow the touch request for parent scroll on touch of
                    // child view
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });
kyogs
  • 6,766
  • 1
  • 34
  • 50
  • @kyogs I liked your answer and its working also. I have a recycler view and first item of that recyclerView is a nestedScrollView containing a textview. Now using your code i am able to scroll both textview and recyclerView but the textview gets scrolled only when scrolled from area inside nestedScrollView which is blank. What to do if I want scrolling event if i scroll touching the text field – Ankesh kumar Jaisansaria Jul 01 '16 at 11:35
  • 1
    But it stoped the childScroll to scroll – Samir Jul 13 '16 at 12:31
  • its not working. when i debug its not executing onTouchListner – Prasad Feb 15 '17 at 12:50