AnotherBiscuit
AnotherBiscuit

Reputation: 11

RecyclerView isn't scrolling

I'm making an app, which contains a recyclerView with some items in it. The app uses a BottomNavigationView, and three other fragments to show some content. Now, one of those fragments contains just a RecyclerView and isn't scrolling.

I already tried some things, like changing the height of the RecyclerView from match_parent to wrap_content, wrapping it with a LinearLayout, using a NestedScrollView or regular ScrollView, adding app:layout_behavior and even android:scrollbars. Nothing worked though.

The XML file of the layout with the list which isn't scrolling in it:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="55dp">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_users"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</FrameLayout>

I set the ConstrainedLayout below as the parent of the other Fragment, this also contains the BottomNavigationView (this is generated by Android Studio when I created the project btw):

<android.support.constraint.ConstraintLayout 
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/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent">

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="@color/colorPrimary"
        app:itemIconTint="@drawable/bottom_nav_selector"
        app:itemTextColor="@drawable/bottom_nav_selector"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>

Finally, this is inside the Fragment's class, where I set the RecyclerView:

    adapter = new UserListAdapter(list, getContext(), getLayoutInflater(), container);
    RecyclerView recyclerView = v.findViewById(R.id.rv_users);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

    recyclerView.setAdapter(adapter);

I hope one of you guys can help me!

Upvotes: 1

Views: 231

Answers (1)

Uğur Yaşar
Uğur Yaşar

Reputation: 19

Have you enough data to list on recycler for scrolling?

Upvotes: -1

Related Questions