如何在Android的抽屉布局中添加paddingBottom?

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

我正在使用抽屉式布局的android项目。抽屉布局包含许多项目,因此可以滚动。问题是,我需要最后一个项目具有填充底部,以便在滚动到最后一个项目后会有一些间距。

enter image description here

从上面的屏幕截图中,我如何在最后一项“注销”和屏幕末端之间添加一些填充。

我已经尝试将padding bottom添加到抽屉布局中,但仍无法正常工作

 <androidx.drawerlayout.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"
        android:fitsSystemWindows="true"
        tools:openDrawer="start"
        android:paddingBottom="@dimen/_120sdp"
        android:clipToPadding="false">

我也尝试过将导航视图包含在滚动视图中,但也无法正常工作

<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clipToPadding="false"
    android:paddingBottom="@dimen/_120sdp">

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</ScrollView>

我该如何实现?

android android-studio android-layout navigation-drawer drawerlayout
1个回答
0
投票

您需要在padding布局的最后view处添加drawer

android:paddingBottom="@dimen/_120sdp" 
© www.soinside.com 2019 - 2024. All rights reserved.