Customised InfoWindow of Google Map does not render elevation shadow in Android

Viewed 401

I'm using InfoWindow to render any information for marker. In Android, we can define shadow with elevation. But the shadow defined by elevation is not rendered for InfoWindow.

The layout of infoWindow is like this

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/background"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:paddingTop="6dp"
        android:paddingBottom="6dp"
        android:elevation="4dp"
>
    <TextView
            android:id="@+id/main_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:gravity="center_horizontal"
            android:textSize="14sp"
            android:textStyle="bold"
            tools:text="main text"
    />
    <TextView
            android:id="@+id/sub_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/main_text"
            android:layout_centerHorizontal="true"
            android:gravity="center_horizontal"
            android:textSize="11sp"
            tools:text="sub text"/>
</RelativeLayout>

Shape is like this

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners android:radius="500dp"/>
    <solid android:color="@color/white"/>
</shape>

Code snippet is like this

googleMap?.setInfoWindowAdapter(object: GoogleMap.InfoWindowAdapter {
      override fun getInfoContents(marker: Marker?): View? {
          return null
      }

      override fun getInfoWindow(marker: Marker?): View? {
          return layoutInflater.inflate(R.layout.map_info_window, null)
      }

  })

0 Answers
Related