ScrollView中嵌套高德地图MapView,解决触摸冲突

来源:互联网 发布:nginx编译pagespeed 编辑:程序博客网 时间:2024/05/21 09:41
public class MapContainer extends RelativeLayout {    public MapContainer(Context context) {        super(context);    }    public MapContainer(Context context, AttributeSet attrs) {        super(context, attrs);    }    @Override    public boolean onInterceptTouchEvent(MotionEvent ev) {        if (ev.getAction() == MotionEvent.ACTION_UP) {           requestDisallowInterceptTouchEvent(false);        } else {            requestDisallowInterceptTouchEvent(true);//告诉父View不要拦截我的事件        }        return false;    }    @Override    public boolean onTouchEvent(MotionEvent event) {//onTouchListener中返回false此方法才会被调用        return true;    }}

xml中

<cn.com.zhwts.ui.MapContainer    android:id="@+id/map_container"    android:layout_width="match_parent"    android:layout_height="wrap_content">    <com.amap.api.maps.TextureMapView        android:id="@+id/mapWiew"        android:layout_width="match_parent"        android:layout_height="175dp" /> </cn.com.zhwts.ui.MapContainer>参考http://blog.csdn.net/suqisq/article/details/52103657

阅读全文
0 0