在Google Maps V2 for Android中发布自定义infowindow [英] Issue with custom infowindow in Google Maps V2 for Android

查看:148
本文介绍了在Google Maps V2 for Android中发布自定义infowindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何删除自定义infowindow的边缘




这是我的infowindow XML

 <?xml version =1.0encoding =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 =horizo​​ntal>

< 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 $ b $ android 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 =粗体/>

< / LinearLayout>

< / LinearLayout>

我使用一个可实现InfoWindowAdapter的适配器



解决方案是在适配器上覆盖 getInfoContents 覆盖 em> getInfoWindow

  public class MyInfoWindowAdapter实现InfoWindowAdapter 
{
private final查看myContentsView;
private Context ctx;

public MyInfoWindowAdapter(查看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());


返回myContentsView;



$ b code $
$ b


Anyone know how to remove the edges of the custom infowindow

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!

解决方案

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;

    }

}

这篇关于在Google Maps V2 for Android中发布自定义infowindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆