Android coordinatorlayout在底部添加额外的空间

问题描述 投票:0回答:1

我有一个CoordinatorLayout,其中具有AppBarLayout(包含CollapsingToolbarLayout),RecyclerView,并在其下方有一个ImageView。我面临的问题是CoordinatorLayoutImageView下方添加了一些多余的空间,该空间不应出现在UI中。

下面是我的XML的代码

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/root"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:fitsSystemWindows="true">

     <com.google.android.material.appbar.AppBarLayout
         android:id="@+id/appBar"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:fitsSystemWindows="true">

         ......

     </com.google.android.material.appbar.AppBarLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
         app:layout_behavior="@string/appbar_scrolling_view_behavior">

             <androidx.recyclerview.widget.RecyclerView
                 android:id="@+id/myRecyclerView"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />

             <ImageView
                 android:id="@+id/myImage"
                 android:layout_width="match_parent"
                 android:layout_height="100dp"
                 android:contentDescription="@null"
                 android:scaleType="fitXY"
                 android:src="@drawable/static_image" />
     </LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
android android-coordinatorlayout
1个回答
0
投票

将此设置为您的LinearLayout

android:layout_height="wrap_content"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.