Custom infowindow with google maps api v2

后端 未结 4 1084
青春惊慌失措
青春惊慌失措 2020-12-10 15:04

I can customize the content of the infoWindow with a simple block of code:

 private GoogleMap mMap;
 mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

            


        
4条回答
  •  囚心锁ツ
    2020-12-10 15:42

    enter image description here

    use this way...

    myMap.setInfoWindowAdapter(new InfoWindowAdapter() {
    
                    @Override
                    public View getInfoWindow(Marker arg0) {
    
                        ContextThemeWrapper cw = new ContextThemeWrapper(
                                getApplicationContext(), R.style.Transparent);
                        // AlertDialog.Builder b = new AlertDialog.Builder(cw);
                        LayoutInflater inflater = (LayoutInflater) cw
                                .getSystemService(LAYOUT_INFLATER_SERVICE);
                        View layout = inflater.inflate(R.layout.custom_infowindow,
                                null);
                        return layout;
                    }
    
                    @Override
                    public View getInfoContents(Marker arg0) {
    
                        return null;
    
                    }
                });
    

    R.style.Transparent add this in your style.xml

    
    
        #00000000
    

    Edited:

    custom_infowindow.xml

    
    
        
    
    
    

提交回复
热议问题