Closed songzhw closed 9 years ago
参考下这个: /**
@author fangc */ public abstract class BaseAnimAdapter extends BaseAdapter { private int lastPosition = -1;
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { setAnimation(holder.itemView, position); }
private void setAnimation(View viewToAnimate, int position) { if (position > lastPosition) { Animation animation = AnimationUtils.loadAnimation(viewToAnimate.getContext(), R.anim.item_slide_bottom_up); viewToAnimate.startAnimation(animation); lastPosition = position; } }
@Override public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) { super.onViewDetachedFromWindow(holder); holder.itemView.clearAnimation(); }
动画功能已完成,多谢@fangchao3652 指导
"列表加载动画(虽然试过好多次,但是都不能实现首次加载,CardView进入时的动画效果,如果你能知道我如何实现,我将非常感激)"
hi, 不了解你说的是不是这个: LayoutAnimation。
具体的例子,可以查看%android_sdk%\samples\android-15\ApiDemos\src\com\example\android\apis\animation里的例子, 这个例子里,ListView的每个子项加载进来都是有动画的