How to remove white space when attaching fragment to framelayout

I have in my activity a FrameLayout where i attach fragments according to the item selected in my NavigationDrawer. The problem is that the fragment doesnt fill the Framelayout entirely, although the width and height are set to MATCH_PARENT and also i already tried removing padding and margin, but the white space is still there. Here are screenshots that show the problem and also the xml files. How do i remove the white space and make the map fill the entire framelayout?

Fragment width and height

Framelayout width and height

Activity layout:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity">



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/tb_actionbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>


    <FrameLayout
        android:layout_margin="0dp"
        android:padding="0dp"
        android:id="@+id/container"
        android:name="com.example.styledmap.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</LinearLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@android:color/white"
    app:headerLayout="@layout/drawer_header"
    app:menu="@menu/drawermenu"/>

Fragment Layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_fragment"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent"
android:layout_height="match_parent">


<com.google.android.gms.maps.MapView
    android:id="@+id/google_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/tv_delete_marker"
    android:layout_width="match_parent"
    android:layout_height="43dp"
    android:layout_alignBottom="@id/google_map"
    android:layout_marginStart="8dp"
    android:text="@string/tv_delete"
    android:textAlignment="center"
    android:textSize="16sp"
    android:visibility="invisible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />


<Button
    android:id="@+id/btn_add_place"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_margin="16dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="48dp"
    android:background="@drawable/ic_add_circle_black_24dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.871"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/google_map"
    app:layout_constraintVertical_bias="0.92" />


<MapView>删除边距

<com.google.android.gms.maps.MapView
    android:id="@+id/google_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
链接地址: http://www.djcxy.com/p/31474.html

上一篇: 平铺drawable有时延伸

下一篇: 将片段附加到framelayout时如何删除空白区域