创建一个Map容器,自定义MapContainer 类,把MapView放在这个容器内,
获取容器控件对象设置一个方法 mapContainer.setScrollView(scroll);
把ScrollView放进去 ,即可解决滑动冲突;
MapContainer 类:
package lenovo.jiyun.com.jiuyue.ui.weight;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
public class MapContainer extends RelativeLayout {
private ScrollView scrollView;
public MapContainer(Context context) {
super(context);
}
public MapContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setScrollView(ScrollView scrollView) {
this.scrollView = scrollView;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
scrollView.requestDisallowInterceptTouchEvent(false);
} else {
scrollView.requestDisallowInterceptTouchEvent(true);
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return true;
}
}