Home » Android » android – Making ItemDecoration move with Animation

android – Making ItemDecoration move with Animation

Posted by: admin June 15, 2020 Leave a comment


I implemented ItemDecoration into my RecyclerView along with an Animation that plays whenever the RV is loaded. However, I noticed that the decoration appears already at the bounds before the animation completes, and I want to have the decoration move in with the animation at the same time. How would I do this?

So far, I have been entering the animation like so:

    public void onBindViewHolder(final RecyclerVH recyclerVH, final int position) {
    currentNote = data.get(position);
    final String currentTitle = currentNote.getTitle();
    final String currentContent = currentNote.getContent();
    final int currentPosition = currentNote.getPosition();
    String currentAlarmDate = currentNote.getAlarm();

    Log.d("RecyclerView", "onBindVH called: " + currentTitle);
    Log.d("RecyclerView", "Position at: " + currentPosition + " and Adapter Position at: " + recyclerVH.getAdapterPosition());

    // final Info currentObject = data.get(position);
    // Current Info object retrieved for current RecyclerView item - USED FOR DELETE
    Log.d("RecyclerAdapter", "currentAlarmDate is: '" + currentAlarmDate + "'");
    if (currentAlarmDate != null && !currentAlarmDate.equals(" ")) {
        Log.d("RecyclerAdapter", "Current Alarm set for: " + currentAlarmDate);
    } else

    /*recyclerVH.listTitle.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Open new Activity containing note content
            Toast.makeText(this, "Opening: " + currentObject.title, Toast.LENGTH_LONG).show();
    runEnterAnimation(recyclerVH.itemView, position);

private void runEnterAnimation(View itemView, int position) {
    // Starts Animation

    Animation animation = AnimationUtils.loadAnimation(context,
            position >= lastAnimatedPosition ? R.anim.up_from_bottom : R.anim.down_from_top);
    // If true, up_from_button is loaded
    lastAnimatedPosition = position;
    Log.d("RecyclerAdapter", "lastAnimatedPosition is now: " + lastAnimatedPosition);
How to&Answers:

Seems like @Mimmo Grottoli’s answer is the closest thing to a solution. Check out this post: How to disable RecyclerView item decoration drawing for the duration of item animations


You can read the documentation

Or if need to animated decoration you can try this:


Thanks, if you not get your solution from it than please ask me i will try my best to give you a better solution. 🙂