how to turn swiped item back in recyclerview

I’m using RecyclerView and ItemTouchHelpter to detect swipe gestures.
In some applications, I have seen the user swipes the item (and it won’t go further than almost 50 % of the screen), and a background animation starts playing. When the user releases the item, there is a smooth vibration, and the foreground item will back to its first position.
I found out for set limitation for swipe width; I can set dX in onChildDrawmethod:

val foregroundView: View? = viewHolder.itemView.findViewById(
            c, recyclerView, foregroundView, dX / 2, dY,
            actionState, isCurrentlyActive

now, I am wondering how I can reverse, swipe animation, and bring the foreground view back to its first position(at this point, it will go beyond the screen, and because I limited the dX, it is shown half in screen and half out of the screen while I want it backs to the first position after calling onSwiped method)

Source: Android Questions