【问题标题】:RecycleView doesn't ScrollRecyclerView 不滚动
【发布时间】:2020-07-09 02:52:50
【问题描述】:

由于很多原因,这似乎发生了很多,但我无法解决我的问题。我无法滚动我的 RecyclerView,我完全不知道为什么。 我的 recyclerView 包含在另一个布局中(activity_class.xml)

这是我的布局代码:

content_home_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView 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/recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFF"
    tools:context="com.example.schoolteacher.ClassActivity"
    tools:showIn="@layout/activity_class">

</androidx.recyclerview.widget.RecyclerView>

activity_class.xml

<?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"
    tools:context="com.example.schoolteacher.ClassActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#FFFFFF"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:title="@string/classes"/>

    </com.google.android.material.appbar.AppBarLayout>

        <include layout="@layout/content_home_screen" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginEnd="@dimen/fab_margin"
        android:layout_marginBottom="70dp"
        android:src="@drawable/ic_add_fab"
        android:theme="@style/Theme.AppCompat"
        app:backgroundTint="@color/colorPrimary" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/bottombar_menu" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

任何想法,因为我几乎尝试了所有方法。

【问题讨论】:

  • RecyclerView 上是否出现了任何项目,或者它只能不能滚动?
  • 是的项目出现了,但它只是不滚动。
  • 您是否使用 Layout Inspector 工具检查您的 RecyclerView 是否有一些视图,这是在窃取焦点? developer.android.com/studio/debug/layout-inspector

标签: android android-recyclerview scroll


【解决方案1】:

将此添加到 content_home_screen 布局

android:scrollbars="vertical" 

【讨论】:

    猜你喜欢
    • 2018-08-04
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多