Search code examples
androidandroid-scrollviewandroid-recyclerviewswiperefreshlayout

Android RecyclerView in ScrollView in SwipeRefresh is not visible


I have RecyclerView inside ScrollView which is inside SwipeRefresh layout. I have few layouts on top of RecyclerView, but my RecyclerView is not visible, even if i remove other layouts from ScrollView. What do you suggest? I need to put list below some layouts in ScrollView somehow.

<?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"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <include layout="@layout/toolbar"></include>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">    
                ....
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/simpleList"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>

        </ScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>

</LinearLayout>

Tried to give specific height but still not visible o.O

If i replace RecyclerView with ListView, then list is visible.


Solution

  • I just had to put android:fillViewport="true" to SwipeRefreshLayout. And now RecyclerView is visible.