Framelayout的Android布局问题



我正在尝试添加图像视图,但是当我这样做时,它在图像的顶部和底部之间都有很大的空间。我正在使用带有片段的底部导航。我想将图像与空间靠近顶部。我在这个布局上做错了什么?

主要活动

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:design="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.android.gershpark.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/main_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:contentDescription="main image"
            android:src="@drawable/fb_img_1497698892826" />
        <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/frame_layout"
            android:layout_below="@id/main_image"
           />
        <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="8dp"
            android:background="@drawable/shadow"
            android:layout_above="@+id/bot_nav">
        </View>
        <android.support.design.widget.BottomNavigationView
            android:id="@+id/bot_nav"
            android:layout_gravity="bottom"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_light"
            design:itemIconTint='#f8f8f8'
            design:menu='@menu/bot_menu'
          />

    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

家庭碎片

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.gershpark.HomeFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Home"/>

</FrameLayout>

通过添加以下添加来删除那里的间距。

android:adpadViewBounds =" true"

最新更新