【问题标题】:How to add ButtonOverlay on a Map(osmdroid)如何在地图上添加 ButtonOverlay(osmdroid)
【发布时间】:2016-12-03 02:04:37
【问题描述】:

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

【问题讨论】:

    标签: android-studio osmdroid


    【解决方案1】:

    只需将其添加到活动/片段的 android 布局中

    这里的例子: 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>
    

    【讨论】:

    • 不支持所以不显示
    • 安卓支持,为什么osmdroid要重写按钮
    • android 按照它们在布局 xml 中引用的顺序在屏幕上绘制内容,因此布局底部的内容通常绘制在顶部,无论是朝向 xml 顶部的内容
    猜你喜欢
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    • 2017-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多