How to put drawable as a background on InfoWindow (Google Maps API v2 for Android)? -


this custom layout info window:

<relativelayout          xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:background="@drawable/bg_infowindow" >     <linearlayout             android:id="@+id/text_box"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:orientation="vertical" >         <textview              style="@style/textitle"             android:id="@+id/title"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />     <textview              style="@style/textdistance"             android:id="@+id/distance"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />     </linearlayout> </relativelayout> 

and custom adapter:

public class mapinfowindowadapter implements infowindowadapter{      private layoutinflater inflater;     private context context;      public mapinfowindowadapter(context context){         inflater = (layoutinflater) context.getsystemservice( context.layout_inflater_service );         this.context = context;     }      @override     public view getinfocontents(marker marker) {          // getting view layout file         view v = inflater.inflate(r.layout.map_popup, null);          textview title = (textview) v.findviewbyid(r.id.title);         title.settext(marker.gettitle());          textview address = (textview) v.findviewbyid(r.id.distance);         address.settext(marker.getsnippet());          return v;     }      @override     public view getinfowindow(marker arg0) {         // todo auto-generated method stub         return null;     }  } 

and result:

enter image description here

however want custom drawable background info window, how achieve this?

replace codes in getinfocontents getinfowindow. difference between them getinfocontents wraps view in viewgroup default background.

@override public view getinfowindow(marker marker) {      // getting view layout file     view v = inflater.inflate(r.layout.map_popup, null);      textview title = (textview) v.findviewbyid(r.id.title);     title.settext(marker.gettitle());      textview address = (textview) v.findviewbyid(r.id.distance);     address.settext(marker.getsnippet());      return v; }  @override public view getinfocontents(marker arg0) {     // todo auto-generated method stub     return null; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -