嗨,我在我的应用程序中使用mapview。它显示正确,但问题是,当我触摸地图视图它不移动,如果用户想看到附近的位置,他不能移动到那个位置。你可以说mapview没有响应布局中的touchevent。这是我的布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="50px"
android:textSize="20sp"
/>
<TextView
android:id="@+id/link"
android:layout_width="fill_parent"
android:layout_height="50px"
android:autoLink="web"/>
<TextView
android:id="@+id/department"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/count"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/location"
android:layout_width="fill_parent"
android:layout_height="80px" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:id="@+id/latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/zoomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ZoomIn"/>
<Button
android:id="@+id/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Zoom Out"/>
</LinearLayout>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:apiKey="0PmsmqKFKflNmHXD2fwG_vPWnR2gA-YB2QVlIQA"
android:layout_weight="2"
/>
</LinearLayout>
移动到不同的位置当任何视图在任何位置默认被触摸时谁能告诉我为什么它不移动以及我该怎么做才能在触摸事件中移动
如果我正确理解你的问题,那就是当你试图在地图上移动时,它没有做任何事情。在XML
中添加这两行可能会有所帮助android:enabled="true"
android:clickable="true"
在你的代码片段中应该是这样的:
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:apiKey="0PmsmqKFKflNmHXD2fwG_vPWnR2gA-YB2QVlIQA"
android:layout_weight="2"
android:enabled="true"
android:clickable="true"
/>
所以尝试在MapView对象的XML中添加这两行,它应该可以工作
这里有很棒的教程http://mobiforge.com/developing/story/using-google-maps-android?page=1