11

Hello I try to change the default color that have (white) to black, this in the google maps api v2, anyone know how I can do this?

PD: is the margin of infowindow

screenshoot of my problem

this is my code where I change the content of infowindow but need change the margin :S

 GoogleMap map = ....
    map.setInfoWindowAdapter(new InfoWindowAdapter() {

            @Override
            public View getInfoContents(Marker marker) {
                View v = getLayoutInflater().inflate(   
                        R.layout.info_window_layout, null);
                v.setBackgroundColor(Color.BLACK);
                return v;
            }
        });

thanks for reply

Kara
  • 6,115
  • 16
  • 50
  • 57
Vinicius DSL
  • 1,839
  • 1
  • 18
  • 26

2 Answers2

43

Use getInfoWindow instead of getInfoContents to provide full info window. Make sure to set appropriate backgrounds for root view, e.g. something with a triangle at the bottom center.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
  • 3
    possible to still use default info window and on;y remove the padding? Sucks that if all you want to do is remove padding you have to implement the entire window yourself. – lostintranslation Dec 09 '15 at 21:03
  • Well... it's Android. We have to go an extra mile to make things a bit more beautiful. – ekashking Nov 01 '19 at 19:36
8

In InfoWindowAdapter change to

@Override
    public View getInfoWindow(Marker marker) {
        View view = ((Activity)context).getLayoutInflater()
                .inflate(R.layout.map_custom_infowindow, null);
        return view;
    }

    @Override
    public View getInfoContents(Marker marker) {

        return null;
    }
Libin Thomas
  • 1,132
  • 13
  • 17