vigu vigu - 5 months ago 321
Android Question

How to auto scroll up Recycler view in Android?

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.

Please help me out.

Answer

on updating recyclerview try to run this code :

recyclerView.post(new Runnable() {
                        @Override
                        public void run() {
                            //call smooth scroll
                                   recyclerView.smoothScrollToPosition(adapter.getItemCount());
                        }
                    });