3

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

I want to move a LinearLayout to y

Into that LinearLayout I put a button with a Listener.

After the anim of the LinearLayout, that LinearLayout is in new position but the button into that LinearLayout doesn't have the Listener.

The Listener is where the button would be if the android:fillAfter="false".

I tried also with:

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 don't align perfectly the percent into anim android:toYDelta="70%" and params.topMargin = 200;

How do I solve that? thanks

Codeman
  • 12,157
  • 10
  • 53
  • 91
oscaroxy
  • 31
  • 2

3 Answers3

3

Your LinearLayout had been moved seemingly,but it's just visually moved.The LinearLayout is still where it is before the animation.You should re-layout your LinearLayout after the animation using the following code.

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

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

TranslateAnimation Not Working As Expected

Community
  • 1
  • 1
peanut
  • 1,570
  • 1
  • 12
  • 9
0

try this metods for you views

clearanimation() fillenable(false)

Sergey Sheleg
  • 720
  • 6
  • 6
0

I had this same problem.

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

myButton.setOnClickListener(myListener);

after the animation happens.

Hope this helps!

Codeman
  • 12,157
  • 10
  • 53
  • 91
  • 2
    nothing, I tried, I put the listener into "public void onAnimationEnd(Animation arg0) " but the listener rest in old position, that is the position before the animation – oscaroxy Aug 11 '11 at 07:44