如何在 google 地图 android 上的图钉下移动自定义信息 window

How to move custom info window under pin on google maps android

有这样的代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:clipToPadding="false"
    android:orientation="vertical"
    android:background="@drawable/shadow_background"

    >
    <!--android:background="@android:drawable/dialog_holo_light_frame"

    -->
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/white_background"
        >

    <TextView
        android:id="@+id/textView_dialog_event"
        style="@style/PrimaryTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginTop="14dp"
        android:text="text"
        android:textColor="@color/rusty_red"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.605"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView_dialog_date"
        app:layout_constraintVertical_bias="1.0" />

    </android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>

看起来像这样:

infoWindow 必须在这样的标记下:

请告诉我如何实施? 像这样连接到 class:

@Override
public View getInfoWindow(Marker marker) {

    View view = LayoutInflater.from(context).inflate(R.layout.dialog_event_marker, null);

    TextView tvTitle = (TextView) view.findViewById(R.id.textView_dialog_address);
    TextView tvData = (TextView) view.findViewById(R.id.textView_dialog_date);
    TextView tvPoison = (TextView) view.findViewById(R.id.textView_dialog_event);

    tvTitle.setText("title");
    tvData.setText("no title");
    tvPoison.setText("text");
    return view;
}

总的来说,我找到了一个解决方案, 在 OnMarkerClickListener 中,添加了 InfoWindow 的下一行项目。

marker.setInfoWindowAnchor (0.5f, 5f);

其中 0.5f 是标记的中心,5f 是 InfoWindow 的高度。