如何制作像超级一样的标记标签?

时间:2017-11-30 17:19:13

标签: java android google-maps bitmap google-maps-markers

我想在我标记旁边的超级应用程序中显示标记。如何在谷歌地图上制作这样的标签?

我已经尝试添加标题和代码段了。但这不是我非常期待的。

 mMap.addMarker(new MarkerOptions()
                        .position(MELBOURNE)
                        .title("6 min away")
                        .snippet("Pick up point ")
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.pickup_2x)));

enter image description here

这是@Nirmal回答的结果。它仍然不是我想要的 This is what i got with @Nirmal  answer. Its still not what I want exactly

1 个答案:

答案 0 :(得分:5)

info_window_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:orientation="horizontal">

    <wm.com.taxiapp.view.CustomTextView
        android:id="@+id/tv_distance"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2.5"
        android:background="@android:color/black"
        android:gravity="center"
        android:paddingLeft="@dimen/space_10"
        android:paddingRight="@dimen/space_10"
        android:text="2\nMIN"
        android:textColor="@android:color/white"
        android:textSize="@dimen/font_8" />

    <ImageView
        android:id="@+id/iv_scheduled_ride"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2.5"
        android:background="@android:color/black"
        android:gravity="center"
        android:paddingLeft="@dimen/space_10"
        android:paddingRight="@dimen/space_10"
        android:src="@drawable/time"
        android:visibility="gone" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="6"
        android:background="@android:color/white"
        android:orientation="vertical">

        <wm.com.taxiapp.view.CustomTextView
            android:id="@+id/tv_lat"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ellipsize="end"
            android:maxLines="1"
            android:paddingLeft="@dimen/space_5"
            android:paddingRight="@dimen/space_5"
            android:paddingTop="@dimen/space_3dp"
            android:scrollbars="none"
            android:text=" "
            android:textColor="@color/hintColor"
            android:textSize="@dimen/font_12" />

        <wm.com.taxiapp.view.CustomTextView
            android:id="@+id/tv_lng"
            android:layout_width="@dimen/space_100"
            android:layout_height="match_parent"
            android:ellipsize="end"
            android:maxLines="1"
            android:paddingBottom="@dimen/space_3dp"
            android:paddingLeft="@dimen/space_5"
            android:scrollbars="none"
            android:text=""
            android:textColor="@color/hintColor"
            android:textSize="@dimen/font_12" />

    </LinearLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/arrow_right" />

</LinearLayout>

在信息窗口mMap.setInfoWindowAdapter

中对此布局文件进行充气