1、自定义一个viewGroup,继承Relativelayout(或者别的layout)
重点是重写了onInterceptTouchEvent(MotionEvent ev)和onTouchEvent(MotionEvent event)
-
-
-
-
-
- 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;
- }
- }
2、在布局文件中,用上边定义的父控件包裹住高德地图的com.amap.api.maps2d.MapView.当然最外边是咱们的scrollview。