加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 如何在mapview周围绘制边框

发布时间:2020-12-15 05:06:25 所属栏目:Java 来源:网络整理
导读:我试图在单击按钮时在mapView周围绘制边距. 所以这就是我所尝试过的,它不起作用. mapview位于相对布局中. LayoutInflater inflater = getLayoutInflater();LinearLayout mView = (LinearLayout) inflater.inflate( R.layout.map_view_create_ps,mapView,fals
我试图在单击按钮时在mapView周围绘制边距.

所以这就是我所尝试过的,它不起作用. mapview位于相对布局中.

LayoutInflater inflater = getLayoutInflater();

LinearLayout mView = (LinearLayout) inflater.inflate(
                        R.layout.map_view_create_ps,mapView,false);

GeoPoint viewLoc = mapView.getMapCenter();
MapView.LayoutParams params = new MapView.LayoutParams(
                        LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,viewLoc,MapView.LayoutParams.BOTTOM_CENTER);
                mView.setLayoutParams(params);
                mapView.addView(mView);
                mView.setVisibility(View.VISIBLE);

单击按钮时会调用上面的内容

我的create_ps_layout就是这样

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@android:color/transparent">
<LinearLayout android:layout_width="fill_parent"
    android:id="@+id/linearLayout1" android:orientation="vertical"
    android:layout_height="fill_parent"
    android:background="@drawable/rounded_boarder"></LinearLayout>

 </LinearLayout>

可绘制的背景是这样的

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="@color/translucent_black" />
<corners android:bottomRightRadius="30dp"
    android:bottomLeftRadius="30dp" android:topLeftRadius="30dp"
    android:topRightRadius="30dp" />
    <stroke android:width="2dip" android:color="#FFB600"/>
</shape>

这不起作用,但是当你选择按钮时,你们可以指出我在如何在mapview周围绘制边框的正确方向吗?

解决方法

将mapview放在一个RelativeLayout中,并设置RelativeLayout的padding属性,如下所示:

<RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" android:layout_weight="1"
            android:background="#444" android:padding="2dp">

            <com.google.android.maps.MapView
                android:id="@+id/mapView"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:apiKey="YOUR-MAP-KEY"
                android:clickable="true"/>
        </RelativeLayout>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读