简体   繁体   中英

Custom view Translate animation is not working inside recycler view

I have a custom view and i have added translate animation on initiate (onLoad). Its working fine when that view is used normally. But when the view is used inside recycler-view Row layout that animation is not happening properly. Some of the bottom Row having that custom view not showing translate animation. Below code is written in init block. And Recyler-view in implemented as usual.

init{
    Handler().postDelayed({
        val anim = AnimationUtils.loadAnimation(context, 
                       R.anim.translate_alert_to_left)
        startAnimation(anim)
    }, 50)
}

I'd need to see more of your code but I assume the init block is the one in your custom view. It shouldn't really be there, try putting it in onBindViewHolder might do the trick, but if you should only start an animation when you need it rather than in when the View is created

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM