【问题标题】:How to add Google material icon "my location" on google map V2 in android?如何在android的谷歌地图V2上添加谷歌素材图标“我的位置”?
【发布时间】:2016-04-22 08:32:42
【问题描述】:

我正在尝试使用 API v2 在 android 中显示地图。

我想在地图上显示 Google 素材图标“我的位置”。但是,每当我尝试添加布局时,它都不会反映在输出中。

我可以得到没有图标的地图。我需要图标来与地图集成。

当我在片段标签之外编写 ImageButton 代码时,图标显示在预览窗格中,但不在其中。

我应该把 ImageButton 代码放在哪里?

Mylayout.xml 的代码:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </fragment>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/ic_gps"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_my_location_black_18dp" />
</RelativeLayout>

链接:-https://design.google.com/icons/#ic_my_location

【问题讨论】:

  • 您是指默认的“查找我的位置”按钮吗?

标签: android android-studio material-design google-maps-android-api-2


【解决方案1】:

获取您的地图对象 (mMap) 并在其上调用 setMyLocationEnabled(boolean)

mMap.setMyLocationEnabled(true);

这将添加启动“查找我的位置”操作的默认图像按钮。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-25
    • 2014-07-07
    • 1970-01-01
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 2014-01-15
    相关资源
    最近更新 更多