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.youkuaiyun.com/suqisq/article/details/52103657