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

Sha*_*yan 1 android google-maps google-maps-markers google-maps-android-api-2

我需要显示一个Google地图标记的Infowindow,底部没有小三角形.请检查我附上的图像.

在此输入图像描述

我尝试通过更改setInfoWindowAnchor进行设置,但它不起作用.谁可以帮我这个事?

marker_info.setInfoWindowAnchor(0,0)
Run Code Online (Sandbox Code Playgroud)

Dan*_*ent 8

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

为了不使用speechbubble,请使用getInfoWindow()override.

例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;
    }
}
Run Code Online (Sandbox Code Playgroud)

结果:

使用speechbubble

例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;
    }
}
Run Code Online (Sandbox Code Playgroud)

结果:

没有Speechbubble

注意,这是使用的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>
Run Code Online (Sandbox Code Playgroud)