serginator
serginator

Reputation: 123

Some kind of JavaScript's preventDefault for Android

I'm developing an Android app with a big form. The Layout is contained by a ScrollView, so I can scroll up and down through the form.

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

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

It captures the event and draw horizontally, but vertically it draws just 1cm or so and starts to scroll the form.

I've been looking through MotionEvent's methods and trying some things without success, and I'm really lost right now.

Thanks in advance!

Upvotes: 4

Views: 726

Answers (1)

serginator
serginator

Reputation: 123

I put here the solution to mark it as solved:

Ok... I've solved it.

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

So it's solved. Thanks anyway!

Upvotes: 3

Related Questions