You need to extend the HorizontalScrollView
and intercept touch events. What worked for me was the following sample:
public class MyScrollView extends HorizontalScrollView {
public MyScrollView(Context p_context, AttributeSet p_attrs)
{
super(p_context, p_attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent p_event)
{
return true;
}
@Override
public boolean onTouchEvent(MotionEvent p_event)
{
if (p_event.getAction() == MotionEvent.ACTION_MOVE && getParent() != null)
{
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(p_event);
}
}
Then, instead of using the HorizontalScrollView
in your layout XML, you need to use this custom view.
What helped me get to this solution is this post
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…