I was thinking can't we just use ScrollPane combined with LinearLayout when the different grids and flexing of the recycler view is not necessary ? The reason I am asking this is it takes a lot of effort to get a recycler view with binding up and running. Also I did a full test with the scroll pane. I had a LinearLayout inside the scroll pane with lots of buttons in it. I used the layout code below :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".MainActivity"
    android:orientation="vertical">
 
 
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
 
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Cool" />
 
 
        </LinearLayout>
    </ScrollView>
</LinearLayout>

The result is the same as the recycler view.

Can somebody please explain to me if this is a valid approach ?

0

There are 0 best solutions below