0

I use a customized info window so that I can achieve a gray background and white text color. Yet, I get a white frame around it. I want all of the Info Window to be gray, that is including its triangular edge that points to the spot.

I use this code in my Activity:

map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
    @Override  // Use default InfoWindow frame
    public View getInfoWindow(Marker marker) { return null; }
    @Override // Defines the contents of the InfoWindow
    public View getInfoContents(Marker marker) {
        View v = getLayoutInflater().inflate(R.layout.map_info_window, null);
        TextView tv_location = (TextView) v.findViewById(R.id.tv_location);
        tv_location.setText(marker.getTitle());
        return v;
    }});

and this is my layout:

<!--?xml version="1.0" encoding="utf-8"?-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map_info_window"
    android:layout_width="match_parent"
    android:background="@color/light_grey"
    android:orientation="horizontal"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/tv_location"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/white" />

</LinearLayout>
Marinos K
  • 1,779
  • 16
  • 39

1 Answers1

1

You have to override the getInfoWindow () method and inflate you custom layout in that function.

From Documentation

public abstract View getInfoWindow (Marker marker)

Provides a custom info window for a marker. If this method returns a view, it is used for the entire info window. If you change this view after this method is called, those changes will not necessarily be reflected in the rendered info window. If this method returns null , the default info window frame will be used, with contents provided by getInfoContents(Marker).

 @Override  // Use default InfoWindow frame
    public View getInfoWindow (Marker marker){
        View v = getLayoutInflater().inflate(R.layout.map_info_window, null);
        TextView tv_location = (TextView) v.findViewById(R.id.tv_location);
        tv_location.setText(marker.getTitle());
        return v;
    }
    @Override // Defines the contents of the InfoWindow
    public View getInfoContents (Marker marker){
        // TODO Auto-generated method stub
        return null;
    }

So i think you should reverse your function implementation.

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62