Some kind of JavaScript preventDefault for Android

I am developing an Android app with a large form. The layout is contained in ScrollView, so I can scroll up and down the form.

The problem is that I have to capture some draws (signature) in this form. I created a view for it and it has onTouchEvent:

public boolean onTouchEvent(MotionEvent event) { //Here should be some kind of event.preventDefault(); float eventX = event.getX(); float eventY = event.getY(); [...] } 

It captures an event and draws horizontally, but vertically it draws only 1 cm or so and starts to scroll through the shape.

I looked through MotionEvent methods and tried some things without success, and I really got lost right now.

Thanks in advance!

+4
source share
1 answer

I put a solution here to mark it as a solution:

Ok ... I solved it.

 public boolean onTouchEvent(MotionEvent event) { getParent().requestDisallowInterceptTouchEvent(true); float eventX = event.getX(); float eventY = event.getY(); [...] } 

So he decided. Anyway, thanks!

+3
source

Source: https://habr.com/ru/post/1395445/


All Articles