Android的TranslateAnimation动画后重置 [英] Android TranslateAnimation resets after animation

查看:1063
本文介绍了Android的TranslateAnimation动画后重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造一些像SlideDrawer,但与大多数定制,基本上事情是工作,但动画闪烁在最后。

I'm creating something like a SlideDrawer but with most customization, basically the thing is working but the animation is flickering at the end.

要进一步解释,我得到了一个TranslateAnimation那么这个动画它返回到原来的位置,如果我设置setFillAfter然后里面的按钮布局停止工作后。如果我听onAnimationEnd并设置其他的布局View.GONE布局fickers。从它判断是,在动画结束,视图追溯到View.GONE调用之前的原始位置。

To further explain, I got an TranslateAnimation then after this animation it returns back to the original position, if i set setFillAfter then the buttons inside the layout stops working. If i listen to onAnimationEnd and set other's layout to View.GONE the layout fickers. Judging from it is that on animation end, the view goes back to original position before the View.GONE is called.

任何意见将是真棒。谢谢

Any advice would be awesome. Thanks

推荐答案

下面是与此相关的问题<一个实际的错误href="http://$c$c.google.com/p/android-misc-widgets/issues/detail?id=8">http://$c$c.google.com/p/android-misc-widgets/issues/detail?id=8

这基本上指出onAnimationEnd方法并没有真正很好地工作时AnimationListener附加到动画

This basically states that the onAnimationEnd method doesn't really work well when an AnimationListener is attached to an Animation

解决方法是听在观看动画的事件,你在申请的动画例如,如果一开始你是连接动画监听到动画像这样

The workaround is to listen for the animation events in the view to which you were applying the animation to For example if initially you were attaching the animation listener to the animation like this

mAnimation.setAnimationListener(new AnimationListener() {
    @Override
    public void onAnimationEnd(Animation arg0) {
                       //Functionality here
    }

,然后应用到动画到这样一个ImageView的

and then applying to the animation to a ImageView like this

mImageView.startAnimation(mAnimation);

要解决此问题,你现在必须创建一个自定义的ImageView

To work around this issue, you must now create a custom ImageView

public Class myImageView extends ImageView {

,然后覆盖View类的onAnimationEnd方法,并提供所有的功能,有

and then override the onAnimationEnd method of the View class and provide all the functionality there

@Override
protected void onAnimationEnd() {
    super.onAnimationEnd();
    //Functionality here
}

这是正确的解决此问题,提供的功能在过riden观点 - 而不是附着于动画的AnimationListener的onAnimationEnd法> onAnimationEnd方法

This is the proper workaround for this issue, provide the functionality in the over-riden View -> onAnimationEnd method as opposed to the onAnimationEnd method of the AnimationListener attached to the Animation.

这工作是否正常,不再有对动画的结尾任何闪烁。希望这有助于

This works properly and there is no longer any flicker towards the end of the animation. Hope this helps

这篇关于Android的TranslateAnimation动画后重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆