hilepi
hilepi

Reputation: 11

NestedScrolling not working with gridView

I have posted my code below when ever I try to use nestedsroll view the screen dosen't scroll and when i add "android:nestedScrollingEnabled="true"" inside my nestedscrollview the app crashes I dont know why is this happening I am using grid view inside the nested scroll view can somebody help me with this it would be of great use , Thank You

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
         <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="match_parent">
            <ImageView
                android:id="@+id/wheel"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="right"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="100dp"
                android:src="@drawable/mywheel" />

            <GridView
                android:id="@+id/grid"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/wheel"
                android:layout_marginTop="10dp"
                android:numColumns="5"
                android:layout_marginStart="90dp"
                android:layout_marginEnd="90dp"
                />
            <LinearLayout
                android:layout_width="match_parent"
                android:id="@+id/seat_info"
                android:layout_below="@+id/grid"
                android:layout_height="40dp"
                android:orientation="horizontal"
                android:layout_marginTop="10dp"
                android:layout_marginStart="10dp"
                android:weightSum="3"
                android:layout_marginEnd="10dp"
                >


                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:layout_weight="1"
                    android:weightSum="2"
                    android:orientation="horizontal"
                    >

                    <ImageView
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_weight=".5"
                        android:src="@drawable/seat_open"
                        />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_weight="1.5"
                        android:gravity="center_vertical"
                        android:text="Available"
                        android:paddingStart="5dp"
                        />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:layout_weight="1"
                    android:weightSum="3"
                    android:orientation="horizontal"
                    >

                    <ImageView
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_weight=".5"
                        android:src="@drawable/seat_booked"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_weight="2.5"
                        android:gravity="center_vertical"
                        android:paddingStart="5dp"
                        android:text="Unavailable"/>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:layout_weight="1"
                    android:weightSum="2"
                    android:orientation="horizontal"
                    >

                    <ImageView
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_weight=".5"
                        android:src="@drawable/seat_selected"
                        />
                    <TextView
                        android:layout_width="wrap_content"

                        android:layout_height="30dp"
                        android:layout_weight="1.5"
                        android:paddingStart="5dp"
                        android:gravity="center_vertical"
                        android:text="Selected"/>

                </LinearLayout>




            </LinearLayout>
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/seat_info"
                android:paddingBottom="10dp">
                <Button
                    android:id="@+id/bt_booking_details"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="@drawable/circular_button"
                    android:fontFamily="@font/montserrat_regular"
                    android:text="Enter Booking Details"
                    android:layout_marginBottom="10dp"
                    android:layout_alignParentBottom="true"
                    android:textColor="@android:color/white"
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="10dp"
                    android:textSize="17dp"
                    android:textStyle="bold" />
            </RelativeLayout>


        </LinearLayout>

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

Upvotes: 1

Views: 265

Answers (1)

Destroyer
Destroyer

Reputation: 795

GridView already has scrolling built in, so it conflicts with a NestedScrollView. You should be using a RecyclerView with a GridLayoutManager and appbar_scrolling_view_behavior layout behavior in place of the NestedScrollView.

Upvotes: 1

Related Questions