gpt4 book ai didi

java - NavigationDrawer 内的 RecyclerView 不滚动

转载 作者:行者123 更新时间:2023-11-30 10:01:46 25 4
gpt4 key购买 nike

我已经启动了一个项目,在这个项目中,我在 NavigationView 中添加了一个 RecyclerView,但由于某种原因 RecylerView 没有滚动。

https://cdn1.imggmi.com/uploads/2019/7/31/d58464f32d8ebb24885b876f81ce2274-full.png

<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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
tools:openDrawer="end">

<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<include layout="@layout/digikala_navigation_drawer_header" android:id="@+id/navigationDrawerHeader"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/navigationDrawerRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/navigationDrawerHeader">

</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</com.google.android.material.navigation.NavigationView>

...

最佳答案

您应该使用 navigationView 更改内容位置(navigationView 必须是 last-child)

    <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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
tools:openDrawer="end">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
// Content
</LinearLayout>

<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<include layout="@layout/digikala_navigation_drawer_header" android:id="@+id/navigationDrawerHeader"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/navigationDrawerRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/navigationDrawerHeader">

</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</com.google.android.material.navigation.NavigationView>

关于java - NavigationDrawer 内的 RecyclerView 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57280707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com