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.

  • One Google Maps key for all developers?
  • Disable Double Tap Zoom/Unzoom on a webview
  • Android - Hindi Conjuncts Support?
  • DefaultHttpClient or HttpURLConnection on Android
  • What's the correct way to animate a View from one coordinate to another?
  • Android - Failed to find style 'mapViewStyle' in current theme
  • Related posts:

    InputType = PersonName?
    Securing php api to use in android application
    “Service discovery failed” from Android Bluetooth Insecure Rfcomm
    Exception 'open failed: EACCES (Permission denied)' on Android
    Drawing a gradient in Libgdx
    Build Android Library Project With Ant
  • App Crashes On Startup Due To java.lang.IllegalArgumentException: column '_id' does not exist
  • Custom SSL handling stopped working on Android 2.2 FroYo
  • android : How to prevent resizing the window when displaying the virtual keyboard
  • Dagger and Butter Knife vs. Android Annotations
  • Android : Google Photos like Grid View with Zoom Functionality
  • Unable to find System Image in Emulator in Android Studio with Google APIs
  • 4 Solutions collect form web for “How to auto scroll up Recycler view in Android?”

    On updating recyclerview try to run this code :

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

    I use the following code so that the scroll is automatic until the last position:

    recyclerView.smoothScrollToPosition(adapter.getItemCount());
    

    I implement to add a new item to the list.

    Try the bellow method for auto scroll to your particular position.

    adapter = new DeliveriesDateRecycleAdapter(getActivity(),sampleDatedate, position);
                    recyclerviewDates.setAdapter(adapter);
                    adapter.notifyDataSetChanged();
                    recyclerviewDates.smoothScrollToPosition(position);
    

    Note : position – the position of the list that you want to show.

    Have you tried RecyclerView.srollTo(int x, int y)?

    Edit: Try RecyclerView.scrollTo(0, 0) directly after you have send or received the last message.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.