You can try to put your Recyclerview
inside a HorizontalScrollingView
and disable the vertical scrolling for your Recyclerview
:
Your .xml file may look like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<HorizontalScrollView
android:id="@+id/myHorizontalScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/myRecyclerView"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</HorizontalScrollView >
</LinearLayout >
In your code you have to override canScrollVertically
of your GridLayoutManager
:
Java:
GridLayoutManager mLayoutManager = new GridLayoutManager(this, 100) {
public boolean canScrollVertically() {
return false;
}
};
Kotlin:
val mLayoutManager = object : GridLayoutManager(this, 100) {
override fun canScrollVertically() : Boolean {
return false
}
}
It is possible that the 100 rows are too much to display them at once on your screen. To solve this, just don't deactivate the vertical scrolling in the GridLayoutManager
.