地图标记信息 window 底部没有小三角形

Map marker info window without small triangle at bottom

我需要显示 Google 地图标记的信息窗口,底部没有小三角形。请检查我附上的图片。

我尝试通过更改 setInfoWindowAnchor 进行设置,但没有成功。谁能帮我解决这个问题?

marker_info.setInfoWindowAnchor(0,0)

要使用 speechbubble,请使用 getInfoContents() 覆盖。

为了不使用语音气泡,请使用 getInfoWindow() 覆盖。

示例 1:

public class MyCustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

    private final View myContentsView;

    MyCustomInfoWindowAdapter() {
        myContentsView = getLayoutInflater().inflate(
                R.layout.info_window, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        return null;
    }

    @Override
    public View getInfoContents(Marker marker) {

        TextView tvTitle = ((TextView) myContentsView
                .findViewById(R.id.txtTitle));
        TextView tvSnippet = ((TextView) myContentsView
                .findViewById(R.id.txtSnippet));

        tvTitle.setText(marker.getTitle());
        tvSnippet.setText(marker.getSnippet());

        return myContentsView;
    }
}

结果:

示例 2:

public class MyCustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

    private final View myContentsView;

    MyCustomInfoWindowAdapter() {
        myContentsView = getLayoutInflater().inflate(
                R.layout.info_window, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        TextView tvTitle = ((TextView) myContentsView
                .findViewById(R.id.txtTitle));
        TextView tvSnippet = ((TextView) myContentsView
                .findViewById(R.id.txtSnippet));

        tvTitle.setText(marker.getTitle());
        tvSnippet.setText(marker.getSnippet());

        return myContentsView;
    }

    @Override
    public View getInfoContents(Marker marker) {

       return null;
    }
}

结果:

注意,这里是使用的 info_window.xml 布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp"
    android:orientation="vertical"
    android:background="#000000">

    <TextView
        android:id="@+id/txtTitle"
        android:textColor="#D3649F"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/txtSnippet"
        android:textColor="#D3649F"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>