【问题标题】:Custom animation when item removed in recycleview在回收站视图中删除项目时的自定义动画
【发布时间】:2021-04-14 09:43:04
【问题描述】:

我正在尝试在删除项目时淡出项目,然后折叠回收视图。但它不起作用。 请帮帮我

for(Object appData : mInvisibleEntries){
       mVisibleEntries.remove(appData);
}

for(View view:viewHoldersList){
       Animation a = new AlphaAnimation(1.00f, 0.00f);
       a.setDuration(2000);
       view.startAnimation(a);
}
notifyItemRangeRemoved(MAX_VISIBLE_APPS_COUNT + 1, mInvisibleEntries.size());
collapseRv();

private void collapseRv(){
    final int initialHeight = mRecyclerView.getMeasuredHeight();
    ValueAnimator valueAnimator = ValueAnimator.ofInt(initialHeight,HEIGHT_VIEW_APPDATA*3+HEIGHT_SECTION_FOOTER);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRecyclerView.getLayoutParams().height = (int) animation.getAnimatedValue();
            mRecyclerView.requestLayout();
        }
    });
    valueAnimator.setInterpolator(new DecelerateInterpolator());
    valueAnimator.setDuration(2000);
    valueAnimator.start();
}

【问题讨论】:

    标签: android animation expandablerecyclerview


    【解决方案1】:

    为了使它更简单,你可以使用像https://github.com/wasabeef/recyclerview-animators这样的库

    【讨论】:

    • 如我所见,使用 SimpleItemAnimator 相当复杂
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-16
    • 2018-05-09
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多