【问题标题】:Insert recycler view item with animation插入带有动画的回收站视图项
【发布时间】:2019-03-04 17:53:30
【问题描述】:

我已经在我的项目中集成了聊天功能,因此我有一个消息回收器视图。如何插入带有动画的每个新项目(从底部)?我已经尝试使用notifyItemRangeChanged()notifyItemInserted() 插入项目,但动画不是那么流畅

【问题讨论】:

    标签: android animation android-recyclerview chat


    【解决方案1】:

    试试这个,它对我有用 在您的适配器中,

    动画动画 = AnimationUtils.loadAnimation(context, R.anim.bottom_up); holder.itemView.startAnimation(动画);

    【讨论】:

      【解决方案2】:

      DefaultItemAnimator 负责在适配器收到通知时平滑过渡

      所以,当你初始化你的 recyclerview 时添加以下内容...在notifyItemInserted(poisition) 之前

      recyclerView.setItemAnimator(new DefaultItemAnimator());
      

      【讨论】:

      • RecyclerView默认使用DefaultItemAnimator
      猜你喜欢
      • 1970-01-01
      • 2017-03-23
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      相关资源
      最近更新 更多