添加轮EGDE到地图标记 [英] Add round egde to a map marker

查看:153
本文介绍了添加轮EGDE到地图标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是InfoWindowAdapter添加自定义信息窗口,以我的marker.Everything是好的,除了一件事,我不能找到一种方法,有一个圆边为我的信息窗口

我就用这将是非常有益的。

谷歌mapV2.Any code段
解决方案

  gMap.setInfoWindowAdapter(新InfoWindowAdapter(){

        @覆盖
        公共查看getInfoWindow(标记为arg0)
        {
            查看vMapInfo =((活动)范围内).getLayoutInflater()膨胀(R.layout.map_info_layout,空)。
            返回vMapInfo;
        }

        @覆盖
        公共查看getInfoContents(标记为arg0)
        {
            //视图V = getLayoutInflater()膨胀(R.layout.map_info_layout,空)。
            返回null;

        }
    });
 

map_info_layout.xml

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:背景=@可绘制/ bg_map_info
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直
机器人:重力=center_horizo​​ntal
 >

< RelativeLayout的
    机器人:layout_width =250dp
    机器人:layout_height =45dp
    机器人:背景=@可绘制/ bg_map_info
    机器人:paddingTop =0dp
    机器人:paddingBottom会=0dp
    机器人:以下属性来=5DP
    机器人:paddingRight =5DP
     >

    <的TextView
        机器人:ID =@ + ID / tvMapStoreName
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =3DP
        机器人:layout_marginTop =2DP
        机器人:layout_marginLeft =5DP
        机器人:layout_marginRight =5DP
        机器人:layout_toLeftOf =@ + ID / ivMapGo
        机器人:ellipsize =结束
        机器人:行=1
        机器人:文本=测试文本测试文本测试文本测试文本
        机器人:文字颜色=#FFFFFF
        机器人:TEXTSIZE =@扪/ txt_size_common
        机器人:TEXTSTYLE =黑体/>

    < ImageView的
        机器人:ID =@ + ID / ivMapGo
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentRight =真
        机器人:layout_centerVertical =真
        机器人:SRC =@可绘制/ ic_launcher/>

    <的TextView
        机器人:ID =@ + ID / tvMapStoreDistance
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignLeft =@ + ID / tvMapStoreName
        机器人:layout_below =@ + ID / tvMapStoreName
        机器人:行=1
        机器人:文本=100英里
        机器人:文字颜色=#FFFFFF
        机器人:TEXTSIZE =12dp
        机器人:TEXTSTYLE =正常/>

< / RelativeLayout的>



< / LinearLayout中>
 

和下面是信息窗口背景的XML。

bg_map_info.xml

 < XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
<项目>
    <形机器人:形状=矩形>
        <梯度安卓角= -  90机器人:startColor =#a0333333
            机器人:endColor =#a0000000/>
        <角落
            机器人:bottomLeftRadius =5DP
            机器人:bottomRightRadius =5DP
            机器人:topLeftRadius =5DP
            机器人:topRightRadius =5DP/>

    < /形状>
< /项目>
<项目的android:顶部=20dp>
    <形机器人:形状=矩形>
        <梯度安卓角= -  90机器人:startColor =#7000
            机器人:endColor =#7000/>
        <角落
            机器人:bottomLeftRadius =5DP
            机器人:bottomRightRadius =5DP
            机器人:topLeftRadius =5DP
            机器人:topRightRadius =5DP/> < /形状>
< /项目>
< /层列表>
 

I am using a InfoWindowAdapter to add a custom infowindow to my marker.Everything is fine except for one thing, I cant find a way to have a round edge for my infowindow

I am using google mapV2.Any code snippet regarding this would be really helpfull

解决方案

 gMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) 
        {
            View vMapInfo = ((Activity) context).getLayoutInflater().inflate(R.layout.map_info_layout, null);
            return vMapInfo;
        }

        @Override
        public View getInfoContents(Marker arg0) 
        {
            //View v = getLayoutInflater().inflate(R.layout.map_info_layout, null);
            return null;            

        }
    });

map_info_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/bg_map_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
 >

<RelativeLayout
    android:layout_width="250dp"
    android:layout_height="45dp"
    android:background="@drawable/bg_map_info"
    android:paddingTop="0dp"
    android:paddingBottom="0dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
     >

    <TextView
        android:id="@+id/tvMapStoreName"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp"
        android:layout_marginTop="2dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_toLeftOf="@+id/ivMapGo"
        android:ellipsize="end"
        android:lines="1"
        android:text="test text test text test text test text "
        android:textColor="#ffffff"
        android:textSize="@dimen/txt_size_common"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/ivMapGo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tvMapStoreDistance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tvMapStoreName"
        android:layout_below="@+id/tvMapStoreName"
        android:lines="1"
        android:text="100 Miles"
        android:textColor="#FFFFFF"
        android:textSize="12dp"
        android:textStyle="normal" />

</RelativeLayout>



</LinearLayout>

and the below is the XML of info window background.

bg_map_info.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> 
    <shape android:shape="rectangle">
        <gradient android:angle="-90" android:startColor="#a0333333"
            android:endColor="#a0000000" />
        <corners 
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp" 
            android:topRightRadius="5dp" />         

    </shape>
</item>
<item android:top="20dp"> 
    <shape android:shape="rectangle">
        <gradient android:angle="-90" android:startColor="#70000000"
            android:endColor="#70000000" />
        <corners 
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp" 
            android:topRightRadius="5dp" />     </shape>
</item>
</layer-list>

这篇关于添加轮EGDE到地图标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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