android – 如何取消动画,但不是结束它?

栏目: Android · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/15189514/how-to-cancel-an-animation-but-not-to-end-it

我班上有TranslateAnimation.动画自动开始.

我设置按钮,如果单击它,动画将被取消(animation.cancel();).

我还为我的班级设置了一个AnimationListener.如果我的动画结束,我将开始一个新的活动(你去菜单).

public void onAnimationEnd(Animation animation) {
    startActivity(new Intent(Class.this, Class2.class));
}

我的应用程序依赖于用户必须在动画结束前单击按钮.

问题是animation.cancel();被承认为动画的结束.

如何以不计入动画结尾的其他方式取消动画?那可能吗?

提前致谢!

animation.cancel()将动画侦听器调用为 API documentation describes

Cancelling an animation invokes the animation listener, if set, to  notify the end of the animation. If you cancel an animation manually,  you must call reset() before starting the animation again.

如果你想在cancel()和onAnimationEnd()上有不同的行为,我会建议一个布尔变量,可以在按钮点击时设置,并且onanimationend检查它是否为真.

翻译自:https://stackoverflow.com/questions/15189514/how-to-cancel-an-animation-but-not-to-end-it


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Collective Intelligence实战

Collective Intelligence实战

阿拉克 / 2010-9 / 58.00元

《Collective Intelligence实战》内容简介:在互联网上,利用用户的集体智慧是成功的关键。集体智慧是一种新兴的编程技术,可让您从人们访问web和与web交互的过程中找到有价值的模式、发现这些访问者之间的关系和确定他们的个人偏好及习惯等。《collective Intelligence实战》首先介绍了集体智慧的原则和构建更具交互性网站的思想,然后通过示例开发了一个直接可用的基于Ja......一起来看看 《Collective Intelligence实战》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具