Skip to main content

If you want to scroll automatic without show scroll motion then you need to write following code:

If you want to scroll automatic without show scroll motion then you need to write following code: **=> mRecyclerView.getLayoutManager().scrollToPosition(position);** If you want to display scroll motion then you need to add following code. =>Step 1: You need to declare SmoothScroller. ; 

If you want to display scroll motion then you need to add following code. =>Step 1: You need to declare SmoothScroller.

RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this.getApplicationContext()) { @Override protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } }; =>step 2: You need to add this code any event you want to perform scroll to specific position. =>First you need to set target position to SmoothScroller. **smoothScroller

=>step 2: You need to add this code any event you want to perform scroll to specific position. =>First you need to set target position to SmoothScroller.

smoothScroller.setTargetPosition(position);** =>Then you need to set SmoothScroller to LayoutManager.;  **mRecyclerView

=>Then you need to set SmoothScroller to LayoutManager.

mRecyclerView.getLayoutManager().startSmoothScroll(smoothScroller);**; 
If you want to scroll automatic without show scroll motion then you need to write following code: **=> mRecyclerView.getLayoutManager().scrollToPosition(position);** If you want to display scroll motion then you need to add following code. =>Step 1: You need to declare SmoothScroller.  RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this.getApplicationContext()) { @Override protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } }; =>step 2: You need to add this code any event you want to perform scroll to specific position. =>First you need to set target position to SmoothScroller. **smoothScroller.setTargetPosition(position);** =>Then you need to set SmoothScroller to LayoutManager.  **mRecyclerView.getLayoutManager().startSmoothScroll(smoothScroller);** 

If you want to scroll automatic without show scroll motion then you need to write following code:

mRecyclerView.getLayoutManager().scrollToPosition(position); 

If you want to display scroll motion then you need to add following code. =>Step 1: You need to declare SmoothScroller.

RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this.getApplicationContext()) { @Override protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } }; 

=>step 2: You need to add this code any event you want to perform scroll to specific position. =>First you need to set target position to SmoothScroller.

smoothScroller.setTargetPosition(position); 

=>Then you need to set SmoothScroller to LayoutManager.

mRecyclerView.getLayoutManager().startSmoothScroll(smoothScroller); 
Source Link
Paras Santoki
  • 841
  • 11
  • 26

If you want to scroll automatic without show scroll motion then you need to write following code: **=> mRecyclerView.getLayoutManager().scrollToPosition(position);** If you want to display scroll motion then you need to add following code. =>Step 1: You need to declare SmoothScroller. RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this.getApplicationContext()) { @Override protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } }; =>step 2: You need to add this code any event you want to perform scroll to specific position. =>First you need to set target position to SmoothScroller. **smoothScroller.setTargetPosition(position);** =>Then you need to set SmoothScroller to LayoutManager. **mRecyclerView.getLayoutManager().startSmoothScroll(smoothScroller);**