Scroll RecyclerView up accordingly when keyboard opens

后端 未结 7 1855
情歌与酒
情歌与酒 2021-01-12 15:34

I have created a chat activity and like facebook messenger, there is an EditText at the bottom and above is the RecyclerView of messages. When Keyboard opens, I want to scro

相关标签:
7条回答
  • 2021-01-12 16:25

    I had the same problem, what I did is when the keyboard opens, I scroll the recyclerView to the last item in the recyclerView, so no items will be hidden. I think this is much easier than the way you were proposing. So the code will be as follows:

      recyclerView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    recyclerView.scrollToPosition(recyclerView.getAdapter().getItemCount() - 1);
                }
            }, 300);
    
    0 讨论(0)
提交回复
热议问题