1

I want to add animations to my recyclerview, I tried using animateLayoutChanges but that crashes my app on startup, so i just changed my adapter and used this piece of code called in onBindViewHolder:

private static int lastPosition = -1;
    private void setAnimation(View v, int position){
        if( v == null ) {
            System.err.println("view is null. No animation");
            return;
        }
        if( position > lastPosition){

            TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0.0F, 1, 0.0F, 1, -1.0F, 1, 0.0F);
            translateAnimation.setDuration(300);
            v.startAnimation(translateAnimation);
            lastPosition = position;
        }
    }

This works, except some views start getting stuck in their position after i scroll. This is before I scroll(you can already see the first item is already stuck though) and after: http://imgur.com/a/RDRxu . It's not only the first item that gets stuck, after I scroll a bit other items start getting stuck but I can't understand if there's a logic to it

Marco Cutecchia
  • 1,045
  • 1
  • 9
  • 14
  • 2
    http://stackoverflow.com/questions/26724964/how-to-animate-recyclerview-items-when-they-appear, I feel the answer in this will help your predicament. Refer to the 'Problems on fast scroll' section. – BIW Sep 24 '16 at 21:51
  • Yep, that fixed it. Thanks – Marco Cutecchia Sep 25 '16 at 09:01

0 Answers0