1

我實現perfect answerchose007,使InfoWindow通過Google Maps API2在我的應用程序中可點擊。唯一的問題是,我想讓InfoWindow透明(使其成爲泡沫狀)。我可以用非交互式的信息窗口使用樣式的包裝做到這一點:如何通過谷歌地圖API2實現Android交互式InfoWindow透明

gMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { 

     @Override 
     public View getInfoWindow(Marker marker) { 

      ContextThemeWrapper cw = new ContextThemeWrapper(
       getApplicationContext(),R.style.TransparentDialog); 
       LayoutInflater inflater = (LayoutInflater) cw 
       .getSystemService(LAYOUT_INFLATER_SERVICE); 
      View layout = inflater.inflate(R.layout.map_bubble, 
       null); 
      return layout; 
     } 

信息窗口顯示爲透明的,但它是不可能的設置窗口中的內容:

@Override 
     public View getInfoContents(Marker marker) { 
      // Setting up the infoWindow with current's marker info 
     TextView bubHd = (TextView) infoWindow.findViewById(R.id.bubble_hd); 
     bubHd.setText(places.get(placeId).getTitle()); 
      . 
      . 
      . 

它是沒有更多的交互性,因爲互動性也設置在getInfoContents裏面,在我看來,如果getInfoWindow返回非null結果,則根本不會調用此方法。

有誰知道,如何讓Google地圖上的交互InfoWindow透明?

回答

2

信息窗口顯示爲透明的,但它不是可以設置窗口的內容在getInfoContents()

正確。如果getInfoWindow()返回非null值,則應該返回完整信息窗口,其中完整內容,並且getInfoContents()將不會被調用。將您的getInfoContents()方法正文語句移至getInfoWindow()