Android Question Scrollview inside another Scrollview will not scroll

raezenkane

Member
Licensed User
Longtime User
My Main Layout has a TabHost. I load a scrollview into each Tab Page, then load a Layout into the scrollview.
The problem is, a scrollview in one of the layouts will not scroll, the Tab Page scrollview consumes the event.
If I do this:
B4X:
Activity.LoadLayout("Main")
        tabPages.AddTab("Points", "Points")
the scrollview in the Points layout scrolls normally.

But if I do this:
B4X:
Activity.LoadLayout("Main")
        scvPointsLAO.Initialize(100%y)
        scvPointsLAO.Panel.LoadLayout("Points")
        tabPages.AddTab2("Points", scvPointsLAO)
The big containing scrollview, scvPointsLAO, scrolls when I click on the scrollview in the Points Layout.

Any help would be greatly appreciated.

John
 

raezenkane

Member
Licensed User
Longtime User
What about the Reflections Library? Can I tell the encapsulating Scrollview to allow touch events using that?
Maybe like this in the Reflections Library somehow...
B4X:
down vote
 
    sv01 = (ScrollView) findViewById(R.id.popup_sf_event_scroll_01);
    sv02 = (ScrollView) findViewById(R.id.popup_sf_event_scroll_02);
 
    sv02.setOnTouchListener(new OnTouchListener() {
 
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP)
                sv01.requestDisallowInterceptTouchEvent(false);
        else
                sv01.requestDisallowInterceptTouchEvent(true);
 
        return false;
        }
    });
 
Upvote 0

raezenkane

Member
Licensed User
Longtime User
Yes you can disable the touch event interception of the main ScrollView, but in this case, why do you use a ScrollView? And not a panel?

Because the Containing Scrollview can be allowed to function normally, scrolling contents as needed until the internal scrollview is touched. The internal scrollview then requests the containing scrollview to disallow the interception of touch events, which allows the internal scrollview to scoll IT'S contents...when the touch event ends for the internal scrollview, it returns events control to the containing scrollview. If I had this in a panel, it would not automatically handle scroll events.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Because the Containing Scrollview can be allowed to function normally, scrolling contents as needed until the internal scrollview is touched. The internal scrollview then requests the containing scrollview to disallow the interception of touch events, which allows the internal scrollview to scoll IT'S contents...when the touch event ends for the internal scrollview, it returns events control to the containing scrollview. If I had this in a panel, it would not automatically handle scroll events.
It's a good reason. Thanks for the explanation.
 
Upvote 0

jinxaw

Member
Licensed User
Longtime User
Hi,
@raenzenkane: Did your solution work out as needed? I have a very similar problem right now, but i don't know where to put the reflection part. In the 2nd scrollview the scrollchanged event is never raised. So where do i put the requestDisallowInterceptTouchEvent(true)? :(

best regards,
Daniel
 
Upvote 0
Top