如何在地图上添加 ButtonOverlay(osmdroid)

How to add ButtonOverlay on a Map(osmdroid)

我想添加一个按钮叠加层,但它不应基于地理点,而应基于屏幕。所以每当我滚动地图时,该按钮应该仍然存在并且会保持在那个位置,我该怎么做?

只需将它添加到您的 android 布局中即可 activity/fragment

这里的例子: https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/res/layout/sample_cachemgr.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tilesource="Mapnik" />

    <Button android:id="@+id/btnCache"
        android:layout_width="fill_parent"
        android:text="Cache Manager"
        android:layout_height="wrap_content"></Button>

</RelativeLayout>