I implemented the new SwipeRefreshLayout
component in my application and it works well with any vertical views, like ListView
, GridView
and ScrollView
.
It behaves very bad with horizontal views, like HorizontalScrollView
.
When scrolling to the right or left, the SwipeRefreshLayout
view caches the touch, prevents the HorizontalScrollView
from receiving it and starts scrolling vertically to perform the refresh.
I tried solving this issue as I previously solved issues with vertical ScrollView
with ViewPager
inside, using requestDisallowInterceptTouchEvent
but it didn't work. I also noticed that this method is overridden in the original SwipeRefreshLayout
class without returning the super. Google's developer left a comment instead "//Nope.
" :)
Because SwipeRefreshLayout
component is relatively new, I couldn't find a solution that fixes the horizontal scroll issue while still allowing the swipe to refresh view to track and handle vertical scrolling so I thought I'll share my solution with hopes it will spare someone an hour or two.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…