I used this solution to move to the bottom of the recycler view when user hit send button to send text in EditText. It works well if I input a single line of EditText, however if the EditText has multiple lines in it, the smoothScrollToPosition(message_container.getAdapter().getItemCount() - 1)
wont work properly. Assume that my EditText has 4 lines, so the view just scrolls to the first line, not the end of the EditText. Is there any workaround for this? thank kiu.
Asked
Active
Viewed 78 times
0

Dennis Nguyen
- 278
- 2
- 9
-
can you share your design – Avinash Feb 10 '20 at 04:57
2 Answers
0
item_recyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recycler, int dx, int dy) {
if (!shouldScroll) {
recycler.scrollTo(0, 0);
item_recyclerview.requestFocus();
}
}
});

eagerprince
- 115
- 1
- 5
-
-
shouldScroll is boolean make it false or you can remove it will work – eagerprince Feb 10 '20 at 09:54
0
I had a mistake that I put the recycler view inside a scroll view, so the code I used above didn't work like expected, just remove the scroll view and everything is normal again.

Dennis Nguyen
- 278
- 2
- 9