Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think I found a simpler solution, only this uses a subclass of ViewPager instead of (its parent) ScrollView.</p> <p><strong>UPDATE 2013-07-16</strong>: I added an override for <code>onTouchEvent</code> as well. It could possibly help with the issues mentioned in the comments, although YMMV.</p> <pre><code>public class UninterceptableViewPager extends ViewPager { public UninterceptableViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean ret = super.onInterceptTouchEvent(ev); if (ret) getParent().requestDisallowInterceptTouchEvent(true); return ret; } @Override public boolean onTouchEvent(MotionEvent ev) { boolean ret = super.onTouchEvent(ev); if (ret) getParent().requestDisallowInterceptTouchEvent(true); return ret; } } </code></pre> <p>This is similar to <a href="https://android.googlesource.com/platform/frameworks/base/+/android-4.2.2_r1.2/core/java/android/widget/Gallery.java" rel="noreferrer">the technique used in android.widget.Gallery's onScroll()</a>. It is further explained by the Google I/O 2013 presentation <a href="http://www.youtube.com/watch?list=PLOU2XLYxmsIJOOTFfYzhR2d-rcSbBbEE&amp;feature=player_detailpage&amp;v=NYtB6mlu7vA#t=1950s" rel="noreferrer">Writing Custom Views for Android</a>.</p> <p><strong>Update 2013-12-10</strong>: A similar approach is also described in <a href="http://www.pushing-pixels.org/2011/03/01/android-bits-and-pieces-event-interception.html" rel="noreferrer">a post from Kirill Grouchnikov about the (then) Android Market app</a>.</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