Reputation: 7248
I have a layout containing several buttons. I want to move this layout to a different position on screen using an animation. When I use a TranslateAnimation
, the layout appears to move however the button press events are still only triggered from their old location. I have attempted to then adjust the view's LayoutParams
in the onAnimationEnd
event - this only resulted in some horrible looking snapping effect when the animation completed. No other answers seem to give a definitive solution to this problem.
How can I move a layout using an animation whilst also ensuring their onClick events are triggered from their new location?
Upvotes: 0
Views: 34
Reputation: 6963
You have to use ObjectAnimator it will actually move your Button with listener attached to their new positions
ObjectAnimator moveButtonAnimator = ObjectAnimator.ofFloat(layout, "translationX", 0, 200f);
moveButtonAnimator.start();
moveButtonAnimator.setDuration(1000);
Upvotes: 1