首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在InfoWindow上将drawable作为背景?

如何在InfoWindow上将drawable作为背景?

提问于 2018-01-29 00:33:34
回答 2关注 0查看 380

这是我的信息窗口的自定义布局:

代码语言:txt
复制
<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>

这是我的自定义适配器:

代码语言:txt
复制
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 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 getInfoWindow(Marker arg0) {
        // TODO Auto-generated method stub
        return null;
    }

}

结果是:

然而,我想要的自定义绘图作为我的信息窗口的唯一背景,如何实现这一点?

相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档