在Android中的MapView上绘制始终居中的叠加层

我想在Android的MapView中绘制一个始终居中的图像叠加层,例如定位标线

我要使用的方法是使用Overlay的onTouchEvent和
MotionEvent.Move移动叠加层的位置.

有更好的方法吗?

解决方法:

您应该能够通过RelativeLayout来实现此目的,该RelativeLayout包含一个MapView和一个ImageView用于居中图像.这是一些示例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示例.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...