Reputation: 1286
I am working on an android project that uses a drawer layout. The drawer layout contains many items and is therefore scrollable. The problem is, I need the last item to have a padding bottom such that there will be some spacing after scrolling to the last item.
From the screenshot above, how can I add some padding between the last item 'Log out' and the end of the screen.
I have tried adding padding bottom to the drawerlayout but its still not working
<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">
I have also tried enclosing navigation view in a scrollview but it is also not working
<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>
This is my last element in the drawer layout
<item
android:paddingBottom="@dimen/_190sdp"
android:title="@string/action">
<menu>
<item
android:id="@+id/nav_rate_us"
android:title="@string/rate_us" />
<item
android:id="@+id/nav_log_out"
android:paddingBottom="@dimen/_120sdp"
android:title="@string/log_out" />
</menu>
</item>
How can I achieve this?
Upvotes: 0
Views: 267
Reputation: 1670
add one dummy items to the end of your menu resource file.
<item
android:title=""
android:enabled="false" >
</item>
Upvotes: 1