Sub EnableScrollInScrollview(Sv As ScrollView)
Private java_object As JavaObject
java_object.InitializeContext
Dim java_view As View
java_view = Sv
java_object.RunMethod("makeMyScrollSmart", Array(java_view))
End Sub
'use below code in relate activity
#If JAVA
import android.view.View;
import android.view.MotionEvent;
import android.widget.ScrollView;
public void makeMyScrollSmart(View myScroll) {
myScroll.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View __v, MotionEvent __event) {
if (__event.getAction() == MotionEvent.ACTION_DOWN) {
// Disallow the touch request for parent scroll on touch of child view
requestDisallowParentInterceptTouchEvent(__v, true);
} else if (__event.getAction() == MotionEvent.ACTION_UP || __event.getAction() == MotionEvent.ACTION_CANCEL) {
// Re-allows parent events
requestDisallowParentInterceptTouchEvent(__v, false);
}
return false;
}
});
}
private void requestDisallowParentInterceptTouchEvent(View __v, Boolean __disallowIntercept) {
while (__v.getParent() != null && __v.getParent() instanceof View) {
if (__v.getParent() instanceof ScrollView) {
__v.getParent().requestDisallowInterceptTouchEvent(__disallowIntercept);
}
__v = (View) __v.getParent();
}
}
#End If