【发布时间】:2020-04-16 18:35:37
【问题描述】:
我有问题:RecyclerView 不滚动。 设计:用菜单覆盖 Image 然后 RecyclerView。 它显示 RecyclerView 但我无法触摸到它只是很烂 我已经厌倦了:用 RecyclerView 替换菜单,但这会造成很大的问题 和 setNestedScrollingEnabled 太。 有爱吗?
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<!-- background Logo-->
<ImageView
android:background="@color/brown"
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/haneenrama"
android:contentDescription="@string/name_offical"
android:scaleType="centerCrop"
></ImageView>
<!-- RecyclerView-->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_marginTop="250dp"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</androidx.core.widget.NestedScrollView>
<!--menu-->
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
tools:openDrawer="end"
android:layout_height="match_parent"
android:id="@+id/drawer_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
android:background="@color/blue"
></androidx.appcompat.widget.Toolbar>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/NavigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
app:itemTextColor="@color/black"
app:itemIconTint="@color/black"
app:itemBackground="@color/rmade"
app:menu="@menu/main_menu"
app:headerLayout="@layout/menu_header"
android:layout_gravity="start"
></com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
【问题讨论】:
-
您真的需要
NestedScrollView吗?这可能是你的问题,至少我有同样的问题......可以删除它吗? -
否则,只需在您的
RecyclerView中尝试此操作:app:layout_behavior="@string/appbar_scrolling_view_behavior" -
您能否发布图片以获得您的 UI 的可视化表示?你能告诉我们你是在 Recyclerview 项目上滚动还是在图像上滚动?
标签: android xml android-recyclerview