Disable scroll animation in RecyclerView

Home / Uncategorized / Disable scroll animation in RecyclerView

Question:
I have a RecyclerView which basically does nothing other than scroll programmatically. The problem is I need this RecyclerView to scroll to position with no animation. This is the code I’m using.
((LinearLayoutManager)recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, offset);

Thanks in advance.


Answer:
You can animate itemView yourself, use two variable startPosition and endPosition for starting position and end position and animate(viewHolder, false) is a function where you can add or remove animation
public void onBindViewHolder(ViewHolder viewHolder, int position) {
final DataModel dataModel = dataList.get(position);

viewHolder.textTittle.setText(dataModel .getTitle());

if (startPosition <=position && position<= endPosition) { animate(viewHolder, false); } else { animate(viewHolder, true); } } animate function like public void animate(RecyclerView.ViewHolder viewHolder) { final Animation animAnticipateOvershoot = AnimationUtils.loadAnimation(context, R.anim.animator_for_bounce); viewHolder.itemView.setAnimation(animAnticipateOvershoot); } Read more

Leave a Reply

Your email address will not be published. Required fields are marked *