2

I have a TextView wrapped in a ScrollView. With some other views around it. When I add this view to my ListView header view, I can scroll the listView, but the scrollView in the header view is not scrollable anymore. Before adding it in the ListView header view I can scroll it with no problem.

Is it an excepted behaviour ? How can I make it scrollable again.

I do not want to hear "Do not put ListView in ScrollView", this is not the case at all here. I have an independent header view, I except views inside to behave correctly.

Thanks!

Dimillian
  • 3,616
  • 4
  • 33
  • 53
  • 2
    Problem is that Touch event is consumed by ListView. So it doesn't get time to get to ScrollView – Bipin Bhandari Jan 13 '14 at 15:52
  • Here is the explanation: http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing – Bipin Bhandari Jan 13 '14 at 15:54
  • WOW, this is really , really weird. I mean, if my finger is inside a scrollview, the touch event should be consumed by the targeted scrollView and nothing else.... – Dimillian Jan 13 '14 at 15:57

2 Answers2

3

This might work for you. In the adapter for your list view do the following:

scrollview.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {

                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });

And in the activity with your list view do this:

listView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                return false;
            }
        });
Dreagen
  • 1,733
  • 16
  • 21
1

Okay I solved my problem with this

innerScrollViw.setOnTouchListener(new ScrollView.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                return false;
            }
        });
Dimillian
  • 3,616
  • 4
  • 33
  • 53