benoffi7
benoffi7

Reputation: 3106

Issue with custom infowindow in Google Maps V2 for Android

Anyone know how to remove the edges of the custom infowindow

enter image description here

This is my XML of the infowindow

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/negro"
    android:orientation="horizontal" >

    <ImageView
         android:id="@+id/image_mapa"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginRight="10dp"
        android:adjustViewBounds="true"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Las Flores"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/blanco"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/snippet"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Resto bar"
            android:textColor="@color/blanco" />

        <TextView
            android:id="@+id/descuento"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="20% OFF"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/verde_habitues"
            android:textStyle="bold" />

    </LinearLayout>

</LinearLayout>

I'm using an adaptar which implements InfoWindowAdapter

Thanks!

Upvotes: 1

Views: 2789

Answers (1)

benoffi7
benoffi7

Reputation: 3106

The solution is on the adapter i nstead of overwriting getInfoContents overwrite getInfoWindow

public class MyInfoWindowAdapter implements InfoWindowAdapter
{
    private final View myContentsView;
    private Context ctx;

    public MyInfoWindowAdapter(View myContentsView, Context ctx)
    {
        this.myContentsView = myContentsView;
        this.ctx = ctx;
    }

    @Override
    public View getInfoContents(Marker marker)
    {
        return null;
    }

    @Override
    public View getInfoWindow(Marker marker)
    {


    TextView tvTitle = ((TextView)myContentsView.findViewById(R.id.title));
        tvTitle.setText(marker.getTitle());        


        return myContentsView;

    }

}

enter image description here

Upvotes: 7

Related Questions