0

我试图在删除项目时淡出项目然后折叠recycleview。但它不起作用。请帮我

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();
}
4

1 回答 1

0

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

于 2021-04-14T09:47:27.450 回答