Listener after animation in android does not work

I set android: fillAfter = "true" in res / anim.

I want to move LinearLayout to y

In this LinearLayout, I put a button using a Listener.

After the animation, LinearLayout LinearLayout is in a new position, but the button in this LinearLayout does not have a Listener.

The listener is where the button will be, if android: fillAfter = "false".

I tried also:

public void onAnimationEnd(Animation arg0) { LayoutParams params = new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); params.topMargin = 200; _mylayout.setLayoutParams(params); _myAnim.setFillAfter(false); } 

But nothing happens, because I do not completely align the percentage in anim android: toYDelta = "70%" and params.topMargin = 200;

How can i solve this? thanks

+3
source share
3 answers

Your LinearLayout was moved apparently, but it's just visually moved. LinearLayout is still where it is before the animation. You must redeploy LinearLayout after the animation using the following code.

 mylayout.layout(x,x,x,x); 

If you have some problems with this, please take a look at my question:

TranslateAnimation does not work as expected

+3
source

I had the same problem.

All you have to do is re-register the listener with

 myButton.setOnClickListener(myListener); 

after the animation.

Hope this helps!

0
source

try these methods to view.

clearanimation () fillenable (false)

0
source

Source: https://habr.com/ru/post/1500097/


All Articles