Невозможно прокрутить RecyclerView - PullRequest
0 голосов
/ 16 апреля 2020

У меня проблема: RecyclerView не прокручивается. Дизайн: обложка Image затем RecyclerView с меню. он показывает RecyclerView, но я не могу прикоснуться к go внизу, просто отстой, я устал: Заменить меню на 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>

Ответы [ 4 ]

0 голосов
/ 17 апреля 2020

Пожалуйста, добавьте android:fillViewport="true" в тег NestedScrollView ...
, затем добавьте android:nestedScrollingEnabled="true" в тег RecyclerView ...

<androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_marginTop="250dp"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:nestedScrollingEnabled="true">
        </androidx.recyclerview.widget.RecyclerView>
    </androidx.core.widget.NestedScrollView>
0 голосов
/ 16 апреля 2020

Попробуйте

recyclerView.setNestedScrollingEnabled(false);
0 голосов
/ 16 апреля 2020

Я положил это. это крышка RecyclerView

    <!--menu-->
<androidx.drawerlayout.widget.DrawerLayout
    android:layout_width="match_parent"
    tools:openDrawer="end"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout">

поэтому я заменяю ее на:

<!--menu-->
<androidx.drawerlayout.widget.DrawerLayout
    android:layout_width="match_parent"
    tools:openDrawer="end"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout">

    <!--    RecyclerView-->

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_marginTop="250dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </androidx.recyclerview.widget.RecyclerView>
0 голосов
/ 16 апреля 2020

Вы можете попробовать удалить NestedScrollView, так как он перекрывается с RecyclerView, и поэтому он не прокручивается.

В противном случае вы можете вставить этот код в RecyclerCode:

* 1007. *

Более подробный ответ можно найти здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...