Note that there are some explanatory texts on larger screens.

plurals
  1. PODispatch TouchEvent to Listview after it's intercepted by parent
    text
    copied!<p>I have a layout which looks something like this:</p> <p><img src="https://i.stack.imgur.com/1rz2M.png" alt="my layout"></p> <p>Inside the ViewPager are a number of Fragments, of which each holds a ListView.</p> <p>Now I want to do this:</p> <p>By scrolling down, the ListView mustn't scroll. Instead the header has to be transformed so it looks like a native ActionBar.</p> <p>I'm doing this by intercepting the TouchEvent in the root layout of my activity. I have overwritten the onInterceptTouchEvent() method of my parent layout and check if a TouchEvent should be intercepted or not, by retrieving the current visible ListView and check if the firstVisibleItem is the first and it's completely visible. If the TouchEvent should be intercepted, my custom OnGesutreListener's onScroll() method is called. So the "animation" progress depends on the scroll offset.</p> <p>All that works really fine. <strong>But now here's my problem</strong>:</p> <p>The transformation is ready and the user still scrolls down. As a user i would expect the ListView to scroll down. But the TouchEvent isn't dispatched to the ListView because it's still intercepted by the parent layout. Only after moving the finger up and down again onInterceptTouchEvent is called again (now the parent layout hasn't to intercept) and the list is scrollable.</p> <p>I tried a few things but they didn't work out for me:</p> <ul> <li>I tried to call my listView's onTouchEvent manually in the onTouchEvent() method of my parent's layout - noting happens </li> <li>I tried to call my listView's onTouchEvent manually in my onScroll method, also this didn't worked out. </li> </ul> <p>Maybe some of you have a clue how to work this out. </p> <p>Thanks a lot and greetz!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload