Search code examples
androidandroid-recyclerviewreloadprogress

switch recycler view layout while loading


I would like to switch the recycler view layout while loading so there will be displayed something indicating the progress:

enter image description here


Solution

  • There is nothing I know of that's built into RecyclerView to handle this. You'll have to implement your own loading behavior

    In the same view that owns your RecyclerView you should add a ProgressBar, when you make your call to fetch the data for your RecyclerView hide the RecyclerView and show the ProgressBar. Switch them back once your data is loaded

    <FrameLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent">
    
        <!-- Your RecyclerView here -->
    
        <ProgressBar
            android:id="@+/progress_bar"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:indeterminate="true"/>
    </FrameLayout>