小编Xpl*_*der的帖子

禁用/暂停RecyclerView动画和/或滚动时仅允许RecyclerView动画

所以基本上,我有一个简单的RecyclerView.Adapter,我有这样的事情:

public void onBindViewHolder(ViewHolder viewHolder, int position) {
    final Session currentSession = sessionList.get(position);

    viewHolder.textTittle.setText(currentSession.getTitle());
    viewHolder.textStartEnd.setText(currentSession.getStartHour() + " - " + currentSession.getEndHour());
    viewHolder.textDate.setText(currentSession.getDateFormatedString());
    viewHolder.textTrack.setText(currentSession.getTrack());
    viewHolder.textRoom.setText(currentSession.getRoom());


    if (position > this.lastPosition) {
        animate(viewHolder, true);
    } else {
        animate(viewHolder, false);
    }

    this.lastPosition = position;
    viewHolder.setClickListener(clickListener, currentSession);
}
Run Code Online (Sandbox Code Playgroud)

当我向上/向下滚动时动画很好但是当我更改所有数据甚至加载RecyclerView(包含CardViews列表)时,动画显得非常混乱.我在尝试更改所有数据时暂时禁用动画,或者在我向上滚动CardView列表时启用动画.

你知道怎么做吗?

谢谢.

animation android android-cardview android-recyclerview

3
推荐指数
1
解决办法
3880
查看次数