Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This has given me headaches and I thought I'd post a solution based on chrisschell's answer because it helped me a lot.</p> <p>Here's the new and improved gallery.</p> <pre><code>public class FriendlyGallery extends Gallery { FriendlyScrollView currScrollView; public FriendlyGallery(Context context) { super(context); } public FriendlyGallery(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onTouchEvent(MotionEvent ev) { return super.onTouchEvent(ev); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { currScrollView = getCurrScrollView(); return super.onInterceptTouchEvent(ev); } @Override public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if(currScrollView != null) currScrollView.scrollBy(0, (int) distanceY); return super.onScroll(e1, e2, distanceX, distanceY); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if(currScrollView != null) currScrollView.fling(-(int) distanceY); return super.onFling(e1, e2, distanceX, distanceY); } private FriendlyScrollView getCurrScrollView() { //I have a load more button that shouldn't be cast to a scrollview int pos = getFirstVisiblePosition(); if(pos != getAdapter().getCount()-1) return (FriendlyScrollView)this.getSelectedView(); else return null; } } </code></pre> <p>And the scrollview.</p> <pre><code>public class FriendlyScrollView extends ScrollView { public FriendlyScrollView(Context context) { super(context); } public FriendlyScrollView(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onTouchEvent(MotionEvent ev) { return false; } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return false; } } </code></pre> <p>Hope this helps and thanks again to chrisschell for pointing me in the right direction.</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