当我在 中使用layout_height="wrap-content"
时CorrdinatorLayout
,底部有一个边距。这是我的代码:
<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/activity_details_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@color/ui_view_primary_background"
android:orientation="vertical">
<include layout="@layout/activity_item_details_appbar_v2"/>
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollview_transaction_details_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_marginBottom="?attr/actionBarSize"
android:background="?attr/ui_v2_color_neutral_100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/transaction_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
当我将CoordinatorLayout
高度更改为 时match_parent
,它工作正常。但是,我想保持它为wrap_content
. 我已经看到很多答案说添加android:fitsSystemWindows="true"
到 coordinatorlayout。但是,对我来说,它不起作用。知道为什么会这样吗?
这是我的屏幕截图。黑色区域是
AppBarLayout
标记为红色的区域是不需要的边距。关于如何解决这个问题的任何想法?谢谢