RecyclerView中如何实现删除时的动画
程序员文章站
2022-05-04 19:53:42
...
adapter.setOnLongItmeClickListener(new MyAdapter.LongClickListener() {
@Override
public void onLongItmeClickListener(View view, final int position) {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 1, 0);
animator.setDuration(2000);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
list.remove(position);
adapter.notifyDataSetChanged();
}
@Override
public void onAnimationCancel(Animator animation) {
list.remove(position);
adapter.notifyDataSetChanged();
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
});