This is my custom layout for my info window:
try this..
custom_infowindow.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#80000000"
android:orientation="vertical">
<ImageView
android:src="@drawable/ic_launcher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"/>
</LinearLayout>
</LinearLayout>
googleMap.setInfoWindowAdapter(new InfoWindowAdapter()
{
public View getInfoWindow(Marker arg0)
{
View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
return v;
}
public View getInfoContents(Marker arg0)
{
return null;
}
});
Replace codes in getInfoContents
with getInfoWindow
. The difference between them is getInfoContents
wraps your View
in ViewGroup
with default background.
@Override
public View getInfoWindow(Marker marker) {
// Getting view from the 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;
}
in addition to the accepted answer i want to mention that if you still want the info window bubble you can use this bubble layout library
then you can set the bubble layout as background of your route view in the custom layout you are inflating.