Open jayattma opened 6 years ago
@jayattma Did U find the way ? i really want to this method
RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(binding.rvVouche .getContext
()) {
@Override
protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
@Override
protected int calculateTimeForScrolling(int dx) {
float MILLISECONDS_PER_PX = calculateSpeedPerPixel(getContext()
.getResources()
.getDisplayMetrics());
return (int) Math.ceil(Math.abs(dx) * MILLISECONDS_PER_PX) + 150;
}
};
smoothScroller.setTargetPosition(voucherAdapter.getAdapterPositionForSectionHeader(position));
binding.rvVoucher.getLayoutManager().startSmoothScroll(smoothScroller);
Try This ...it's work perfect for me
In this line smoothScroller.setTargetPosition(voucherAdapter.getAdapterPositionForSectionHeader(position));
position must be getSection which you get from HeaderViewHolder
getAdapterPositionForSectionHeader(int passYourPosition) is the method already there.
how to do smooth scroll to a perticular section when click on a button.