Kal*_*ani 2 android dispatchevent android-mapview
我想禁用某些区域的调度触摸,以便您理解这里是我的屏幕.

您可以在图像中看到页眉,页脚和Mapview,但是当我点击位置按钮(标题中的右侧)时,我的地图也会收到通知(就像它被触摸),这是我不想要的.我希望只有按钮的onClick事件才能被点击而不是发送事件.
这是我的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>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
您可以覆盖dispatchTouchEvent,并检查用户触摸屏幕的位置.
@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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6582 次 |
| 最近记录: |