How to reverse recyclerView items with CoordinatorLayout as root layout?
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_main_students"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:scrollbars="vertical"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
and app:reverseLayout="true"
not working for recyclerview.
Note: I want reverse recyclerView not reverese collection
2
Answers
solution 1- reverse list of input data
follow- https://www.techiedelight.com/reverse-copy-list-kotlin/
Solution 2
The best solution is to reverse the list. You can do this:
In your xml add this ->
NOTE: if you are doing some operations with the adapter position and the list in the adapter, then first reverse and then pass it to the adapter. Or else you gotta face and issue