Pavlo Kravchenko
Pavlo Kravchenko

Reputation: 375

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

there is such code:

<?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>

It looks like this:

enter image description here

It is necessary that infoWindow was under a marker like this:

enter image description here

Tell me please how it can be implemented? Connect to the class like this:

@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;
}

Upvotes: 1

Views: 683

Answers (1)

Pavlo Kravchenko
Pavlo Kravchenko

Reputation: 375

In general, I found a solution, In the OnMarkerClickListener, the next line item for InfoWindow is added.

marker.setInfoWindowAnchor (0.5f, 5f);

Where 0.5f is the center of your marker, and 5f is how low InfoWindow is.

Upvotes: 1

Related Questions