Return value of ontouch method in Android ontouchevent event (Introduction)

1. If return false, the ontouch event is not successfully executed. After executing the code in ontouch, the ontouch event does not end. Therefore, some components, such as gallery, will automatically execute the code of the ontouch method in its view. If you add your code to the ontouch method and finally return false, you will perform the processing operations in the ontouch method.

2. If return true, you have successfully executed the ontouch method. After executing the code in ontouch, the ontouch event ends. The default ontouch method of components such as gallery will no longer be called. In the ontouch method, we can do many operations, such as move, down, up, etc. if we return false in move, the following events such as flying and up will not be processed.

be careful:

1. If the onintercepttouchevent method in the ViewGroup returns false, the touch screen event will continue to pass down. However, if there is no child view to process the event, that is, the ontouchevent of the child view does not return true, the ViewGroup will finally process the event and execute its own ontouchevent.

2. Onitouch will automatically call onintercepttouchevent before calling. If onintercepttouchevent returns false, ontouchevent will not be called. If onintercepttouchevent is rewritten to return true when it needs to call ontouchevent

The return value (Introduction) of the ontouch method in the Android ontouchevent event above is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>