0

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.

1 Answers1

-1

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);
        }
J.D.
  • 109
  • 1
  • 11