android地图缩放在触摸屏上不工作?
我在水平滚动中使用地图。 我的问题是,当我尝试水平滚动时,效果很好,但当我尝试移动或缩放mapview时,效果不好。为什么? 我想这可能是因为滚动视图滚动功能android地图缩放在触摸屏上不工作?,android,horizontal-scrolling,android-maps-v2,pinchzoom,Android,Horizontal Scrolling,Android Maps V2,Pinchzoom,我在水平滚动中使用地图。 我的问题是,当我尝试水平滚动时,效果很好,但当我尝试移动或缩放mapview时,效果不好。为什么? 我想这可能是因为滚动视图滚动功能 <?xml version="1.0" encoding="utf-8"?> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/horizontal_scroll"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ffffff"
android:fadingEdge="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<!-- Map Panel -->
<RelativeLayout
android:id="@+id/map_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/headerLayout"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="@drawable/greybar_head"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/stpLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/st_icon_new" />
<TextView
android:id="@+id/PropertyTypeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/img_prop_for"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="15dp"
android:paddingRight="30dp"
android:text="For Sale"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<ListView
android:id="@+id/ListItemView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/LeftHeaderLayout"
android:cacheColorHint="@color/transparent"
android:choiceMode="singleChoice"
android:listSelector="@drawable/list_selector" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/mapInnerLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/leftListView"
android:gravity="center_vertical" >
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
class="com.stp.stproperty.shared.MySupportMapFragment" />
</RelativeLayout>
毕竟,我发现问题的解决方案是覆盖horizontal scrollview的ontouch事件,如下所示
public class CustomScrollView extends HorizontalScrollView {
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public boolean onTouchEvent(MotionEvent ev) {
return true;
}
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}
}我无法发布完整的代码,但此xml有一部分。是的,它只能水平滚动,因为您必须在水平滚动视图中添加它。所以它总是水平滚动。如何避免滚动并使地图移动工作@Piyushgupta删除水平滚动视图。我也需要它。因为在滚动时,我几乎没有更多的视图可以显示。