lj wang lj wang - 1 year ago 371
Android Question

how to keep RecyclerView always scroll bottom

I Use Recyclerview Replace with list view
I want to keep Recyclerview always scroll bottom.

ListView can use this method


RecyclerView I use method
smoothScrollToPosition(myAdapter.getItemCount() - 1)

but when Soft keyboard Pop ,its replace RecyclerView content.

Answer Source

This is because RV thinks its reference point is TOP and when keyboard comes up, RV's size is updated by the parent and RV keeps its reference point stable. (thus keeps the top position at the same location)

You can set LayoutManager#ReverseLayout to true in which case RV will layout items from the end of the adapter.

e.g. adapter position 0 is at the bottom, 1 is above it etc...

This will of course require you to reverse the order of your adapter.

I'm not sure but setting stack from end may also give you the same result w/o reordering your adapter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download