在 Maps Fragment 的边框中添加圆角并删除 Fragment 背景

Add rounded corners in border in Maps Fragment and remove the Fragment background

我在地图片段中添加了边框。边角也是圆的。但问题是碎片背景仍然出现在角落里。它只会让整个设计看起来很奇怪。这可以克服吗?我还附上了我的应用程序中出现的问题的屏幕截图。因此,我将不胜感激在这方面的任何帮助。


这是我用来实现我问题中解释的设计的地图代码,以便更好地理解问题。

**activity_maps.xml:**

<RelativeLayout
        android:layout_weight=".5"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp">

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:map="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/map_border_2"
            android:orientation="vertical">
        </LinearLayout>

</RelativeLayout>

Code for implementing the borders is given Below.

**map_border_2.xml (Drawable file):**

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <gradient
                android:gradientRadius="2dp" />
            <stroke
                android:color="@color/glass"
                android:width="10dp" />
            <corners
                android:radius="10dp" />
        </shape>
    </item>
</selector>

In the above code, I need to remove the map fragment background from the four corners. I have added some buttons on the map but I have no issue in that!

上图是我的代码的输出。上图中,需要去掉带圆圈的地方

尝试将此行添加到 RelativeLayoutfragment

android:background="@drawable/map_border_2"

希望对你有用