在android的动画后,监听器不工作 [英] The listener after an animation in android doesn't work
问题描述
我设置的android:fillAfter =在水库真/阿尼姆
I set android:fillAfter="true" in res/anim.
我想一个的LinearLayout移动至Y
I want to move a LinearLayout to y
进入那的LinearLayout我把按钮与一个监听器。
Into that LinearLayout I put a button with a Listener.
所述的LinearLayout的阿尼姆后,在该的LinearLayout是在新的位置,但该按钮成LinearLayout中没有监听器。
After the anim of the LinearLayout, that LinearLayout is in new position but the button into that LinearLayout doesn't have the Listener.
监听器是那里的按钮是,如果机器人:fillAfter =假
The Listener is where the button would be if the android:fillAfter="false".
我想也有:
public void onAnimationEnd(Animation arg0)
{
LayoutParams params = new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.topMargin = 200;
_mylayout.setLayoutParams(params);
_myAnim.setFillAfter(false);
}
但没有任何反应,因为我不完全一致的百分比成动画的android:toYDelta =70%和params.topMargin = 200;
But nothing happens, because I don't align perfectly the percent into anim android:toYDelta="70%" and params.topMargin = 200;
我该怎么解决呢?谢谢
推荐答案
您的LinearLayout已经被转移貌似,但它只是在视觉上moved.The的LinearLayout仍然是它是前animation.You应重新布局后,您的LinearLayout动画使用下列code。
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:
<一个href="http://stackoverflow.com/questions/8848562/translateanimation-not-working-as-expected">TranslateAnimation工作不正常
这篇关于在android的动画后,监听器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!