recyclerview-animators
recyclerview-animators copied to clipboard
Display animation when first time loads
I'm using adapters with recyclerviews.
Animations are displayed only when we scroll through the contents of the recyclerView.
But When the first time fragment loads, How to show animations on items ?
Hi
OK, i will fix.
+1 thanks for this library @wasabeef
im really stuck trying to implement FlipInTopXAnimator, FlipInBottomXAnimator
for the items of the recylerview when the activity/fragment loads
any update on this issue ?!
The cause of first load animation fail is due to the view is not exist when onBindViewHolder is called. My work around is to insert the short time view.animate() function. animate() will be called when the view is rendered on screen. As the duration property is private variable. I override the setter to get the value for animations.
I would like to see if i can show some different animations on first visible items but it's difficult to calculate know the position information inside the adapter. `
public class FirstTimeSlideInRightAnimationAdapter extends SlideInRightAnimationAdapter {
private int mDuration = 300;
private Interpolator mInterpolator = new LinearInterpolator();
public void setDuration(int mDuration) {
super.setDuration(mDuration);
this.mDuration = mDuration;
}
public void setInterpolator(Interpolator mInterpolator) {
super.setInterpolator(mInterpolator);
this.mInterpolator = mInterpolator;
}
public FirstTimeSlideInRightAnimationAdapter(RecyclerView.Adapter adapter) {
super(adapter);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder viewHolder = super.onCreateViewHolder(parent, viewType);
viewHolder.itemView.animate()
.setDuration(1)
.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
Animator[] animators = getAnimators(viewHolder.itemView);
for (Animator animator : animators) {
animator.setDuration(mDuration).start();
animation.setInterpolator(mInterpolator);
}
}
// other empty override function
}).start();
return viewHolder;
}
}
`
You must see #14 maybe there are a way for the solution
@wasabeef I am having this problem too, any way to fix it?
The problem is with SlideInBottomAnimationAdapter.
With the Alpha animation I am not getting this problem...