Ad

How To Enable Scrolling Of Grideview Inside A Recyclerview?

I have a recycler view which the item of this recycler view is like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/question_bkg"
    android:orientation="vertical"
    >
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/questionTitle"
        android:padding="10dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/dynamicLayout"
        android:layout_below="@id/questionTitle"
        android:layout_alignParentLeft="true"></LinearLayout>
    <GridView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/dynamicLayout"
        android:numColumns="2"
        android:id="@+id/questionChoicesRecycler"></GridView>
</RelativeLayout>

When I have set the recyclerView.setNestedScrollingEnabled(true); but still i can not scroll inside gridview. How can I fix this? Or is there a way to use recycler instead of gridview but with 2 item in a row?

Ad

Answer

Put your GridView inside a ScrollView.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

    <GridView
        android:layout_width="match_parent"         
        android:layout_height="match_parent"        
        android:layout_below="@id/dynamicLayout"
        android:numColumns="2"        
        android:id="@+id/questionChoicesRecycler">
    </GridView>

</ScrollView>
Ad
source: stackoverflow.com
Ad