Capture OnTouchMove event in ScrollView, scrollviewtouch
ScrollView in Android captures the OnTouch move event and does not pass it to the child control.
We recommend that you use
Scrollview. requestDisallowInterceptTouchEvent (true );
However, I did not respond after using it.
So I wrote it like this.
scrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { linearLayout.dispatchTouchEvent(event); return false; } });
In this way, the scrollview can be passed to the subcontrol linearlayout, but the problem is that the subcontrol of linearlayout
The MOVE event has not been obtained. Currently, I do not know how to solve it.
A ScrollView is added to the view. How does one respond to the touch event?
UIScrollView itself cannot handle touch events. To achieve this, you must perform touch processing on the subView on UIScrollView in a simple way. For example, to respond to the UIImageView on scrollView, create a subclass of UIImageVIew, the custom UIImageView handles the touch event header file declaration as follows: # import @ protocol ImageTouchDelegate-(void) imageTouch :( NSSet *) touches withEvent :( UIEvent *) event whichView :( id) imageView; @ end @ interface ImageTouchView: UIImageView {id delegate; BOOL delegatrue;} @ property (nonatomic, assign) id delegate; @ end this is the header file, the source file can be like this @ implementation ImageTouchView @ synthesize delegate;-(id) initWithFrame :( CGRect) frame {if (self = [super initWithFrame: frame]) {[self setUserInteractionEnabled: YES]; delegatrue = YES;} return self;}-(BOOL) touchesShouldBegin :( NSSet *) touches withEvent :( UIEvent *) event inContentView :( UIView *) view {return YES ;} -(void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {if (delegatrue) {[delegate imageTouch: touches withEvent: event whichView: self];}
How can we avoid triggering Touch events of internal components during ScrollView scrolling?
You can use onInterceptTouchEvent to intercept the event...