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.
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();
}
}
});
我有一个错误,我将回收器视图放在滚动视图中,所以我上面使用的代码没有按预期工作,只需删除滚动视图,一切又正常了。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.