scroll - Android: How to Prevent Down Press animation of a button when scrolling a list? -
so have imageview want use button. when press button scales little bit down , when release it, button scales original size.
to attach ontouchlistener image:
@override public boolean ontouch(view v, motionevent event) { animation anim; int action = event.getaction(); switch (action){ case motionevent.action_down: // scale down imageview when finger down anim = animationutils.loadanimation(getcontext(), r.anim.poster_scale_down); v.startanimation(anim); return true; case motionevent.action_up: // scale imageview when finger anim = animationutils.loadanimation(getcontext(), r.anim.poster_scale_normal); v.startanimation(anim); break; case motionevent.action_cancel: // scale imageview when action canceled anim = animationutils.loadanimation(getcontext(), r.anim.poster_scale_normal); v.startanimation(anim); break; } return false; } i have series of these imageviews in recyclerview. when scrolling, trigger action_down pressed animation of finger was. annoying!
how prevent this? there better way add animation selector imageview?
edit sort of workaround:
case motionevent.action_cancel: v.clearanimation(); break; when scroll cancel current touch on list item, clear animation. isn't perfect because still cause animation start if you're not swiping fast enough
simply maintain state variable yourself. e.g. when first press down, set variable true, if variable true, not perform animation. when released, set variable false.
Comments
Post a Comment