【发布时间】:2011-09-05 03:01:22
【问题描述】:
我想在 Android 的 MapView 中绘制一个始终居中的图像叠加层,例如定位标线
我要解决的方法是使用 Overlay 的 onTouchEvent 和 MotionEvent.Move 移动覆盖的位置。
有更好的方法吗?
【问题讨论】:
标签: android overlay android-mapview
我想在 Android 的 MapView 中绘制一个始终居中的图像叠加层,例如定位标线
我要解决的方法是使用 Overlay 的 onTouchEvent 和 MotionEvent.Move 移动覆盖的位置。
有更好的方法吗?
【问题讨论】:
标签: android overlay android-mapview
您应该能够使用包含 MapView 和 ImageView 的 RelativeLayout 来完成此操作,以用于居中的图像。这是一些示例 XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.maps.MapView android:id="@+id/google_maps"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="@string/maps_key"/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/mapcenter"/>
</RelativeLayout>
这将使您的图像居中,并减少将图像居中/保持居中所需的任何处理。当然还有其他方法可以用 OverlayItem 做到这一点,如果 XML 方法不起作用,请告诉我,我会发布一个 Overlay 示例。
【讨论】: