I'm trying to implement a custom view in which the user can draw with his finger. Basically, I'm following this tutorial.
Everything seems to be working nice, but, given the fact that I also have 2 buttons underneath the custom view like so:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color"
tools:context=".MainActivity"
android:id="@+id/mainScreen" >
<Button
android:id="@+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:text="@string/save" />
<Button
android:id="@+id/buttonQuery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="@string/query" />
<com.example.myapp.DrawView
android:id="@+id/drawView"
android:background="@color/red"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_above="@id/buttonSave" />
</RelativeLayout>
it actually draws even underneath the buttons and I'm having a hard time understanding why it doesn't capture only the touch events that occur on the DrawView and not outside it. Basically, I can't start the line from above the buttons, but once I start drawing on my view, I can even extend the line outside of it.
As far as I can tell, the DrawView doesn't overflow beneath the buttons, as discussed here so I want to figure out what's going on. Do I really have to check if the events are out of bounds? Does it actually delegate all of the touch events to the currently focused view? Is there any way to change this behavior?
This simple tutorial doesn't have the described issue, but it draws point by point.
Update: Debugging the application, I determined that drawView has size 480x728, while mainScreen has 480x800, so they do not overlap. It continues to register touch events even if they are triggered outside of the drawView, once it has focus. This is what I'm trying to avoid and it would be nice to do it without passing the event coordinates through a big if statement...