I want to disable dispatch touch for some area for your understanding here is my screen.
You can see Header,Footer and Mapview in image but when I clicked on location button(right side in header), My map is also getting notified (like it got touched) which I don't want. I want that only onClick event of button should be clicked not dispatch event.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- include title bar for all screen -->
<include
android:id="@+id/include1"
layout="@layout/titlebar_layout"
android:layout_gravity="top" />
<FrameLayout
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.88"
>
<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.63"
android:apiKey="0VkXbAOFvAq7b6uaGHSmnS2a2VosPxoS6ceHY_g"
android:clickable="true" >
</com.google.android.maps.MapView>
</FrameLayout>
<include
android:id="@+id/include2"
android:layout_gravity="bottom"
android:layout_marginBottom="38dp"
layout="@layout/bottom_layout" />
</LinearLayout>
Any help will be greatly appreciated.
You can override the dispatchTouchEvent
, and check where the user has touched the screen..
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
//first check if the location button should handle the touch event
if(locBtn != null) {
int[] pos = new int[2];
locBtn.getLocationOnScreen(pos);
if(ev.getY() <= (pos[1] + locBtn.getHeight()) && ev.getX() > pos[0]) //location button event
return locBtn.onTouchEvent(ev);
}
return super.dispatchTouchEvent(ev);
}