You can use info window adapter for this purpose , you can also customize the info window by giving your own custom layout
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
// Getting view from the layout file info_window_layout
View v = getParent().getLayoutInflater().inflate(R.layout.windowlayout, null);
// Getting the position from the marker
LatLng latLng = arg0.getPosition();
// Getting reference to the TextView to set latitude
tvLat = (TextView) v.findViewById(R.id.tv_lat);
// Setting the latitude
tvLat.setText(duration);
// Returning the view containing InfoWindow contents
return v;
}
});
here is the custom windowlayout , you can use your own
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_lat"
android:layout_width="wrap_content"
android:text="latitude"
android:drawableRight="@drawable/ic_launcher"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>