问题
I have a recyclerView with 100+ items. When user will open the activity containing the recyclerView, recyclerView's bottom should be visible without any scrolling effect. Directly last page of the adapter should be shown like whatsapp's chatting page.
I have tried by following way, but it is showing the scrolling effect when user opens the activity.
recyclerView.smoothScrollToPosition(list.size());
回答1:
You can scroll to last position of recycler view by adding this line
recyclerView.scrollToPosition(YourArraylist.size()-1);
add this after setting adapter
回答2:
LinearLayoutManager.setReverseLayout(true);
this should do the trick
Documentation
Used to reverse item traversal and layout order. This behaves similar to the layout change for RTL views. When set to true, first item is laid out at the end of the UI, second item is laid out before it etc. For horizontal layouts, it depends on the layout direction. When set to true, If RecyclerView is LTR, than it will layout from RTL, if RecyclerView} is RTL, it will layout from LTR. If you are looking for the exact same behavior of setStackFromBottom(boolean), use setStackFromEnd(boolean)
来源:https://stackoverflow.com/questions/41427468/recyclerview-scrolling-to-the-bottom