I have developed some chat application where i can send and received messages. But the problem is whenever i send or receive messages the recycler view is not scrolling to top so that messages gets diplayed above the keypad.
I have used the above mentioned recycler view android.support.v7.widget.RecyclerView
.
Edit: Try RecyclerView. scrollTo(0, 0) directly after you have send or received the last message. Show activity on this post. try with following method for auto scroll to any position....you can change argument of the "notifyItemChanged" method.
In the above code we have added recycler view to window manger as relative parent layout and add FloatingActionButton. FloatingActionButton supports CoordinatorLayout. So we have used parent layout is CoordinatorLayout. When you click on FloatingActionButton, it will scroll to top position.
To help you build apps with lists, Android provides the RecyclerView . RecyclerView is designed to be very efficient, even with large lists, by reusing, or recycling, the views that have scrolled off the screen.
Recyclerview scroll to bottom using scrollToPositon. After setting the adapter, then call the scrollToPosition function to scroll the recycler view to the bottom.
On updating recyclerview try to run this code :
recyclerView.post(new Runnable() {
@Override
public void run() {
// Call smooth scroll
recyclerView.smoothScrollToPosition(adapter.getItemCount() - 1);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With