Recyclerview is not rolling in inside the Drawerlayout

Asked

Viewed 22 times

-3

I added a Recyclerview in inside a Drawelayout, but for some reason the Recyclerview scroll doesn’t work

acitivty_main.xml

<androidx.drawerlayout.widget.DrawerLayout
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_gravity="start"
                android:fitsSystemWindows="true"
                android:layout_width="match_parent"
                android:background="?android:attr/windowBackground"
                android:orientation="vertical"
                android:layout_height="match_parent">
                <include
                    layout="@layout/main_drawer_header"
                    android:background="?attr/colorPrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="4dp"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
                </LinearLayout>
            </LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>

Mainactivity

//A Lista vai conter os arquivo de um diretório, igual um "FileExplorer"
recyclerAdapter = new RecyclerAdapter(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + PATH);
recyclerView.setAdapter(recyclerAdapter);

2 answers

0

In its Main class, already tried to put the orientation as VERTICAL?

`recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));`

-1


To resolve this, simply place a Scrollview before Recyclerview

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
       <androidx.recyclerview.widget.RecyclerView"
           android:layout_width="match_parent"
           android:layout_height="match_parent"/>
</ScrollView>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.