【发布时间】:2014-11-16 06:49:55
【问题描述】:
我想知道,像 jQuery 一样,有一个选项可以检查任何控件的 android 中动画的剩余时间。喜欢检查完成动画还剩多少毫秒。具体来说就是在当前运行的动画的开始和结束之间运行的监听器。
【问题讨论】:
标签: android multithreading animation asynchronous
我想知道,像 jQuery 一样,有一个选项可以检查任何控件的 android 中动画的剩余时间。喜欢检查完成动画还剩多少毫秒。具体来说就是在当前运行的动画的开始和结束之间运行的监听器。
【问题讨论】:
标签: android multithreading animation asynchronous
嗯,我自己找到了答案。由于我想使用此功能来增加修复时间或动画剩余时间,所以我发现了这个
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class HeightAnimation extends Animation {
protected final int originalHeight;
protected final View view;
protected float perValue;
public HeightAnimation(View view, int fromHeight, int toHeight) {
this.view = view;
this.originalHeight = fromHeight;
this.perValue = (toHeight - fromHeight);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
view.getLayoutParams().height = (int) (originalHeight + perValue
* interpolatedTime);
view.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
}
其中 applyTransformation 给了我剩余时间或进度回调的效果,但它解决了我的问题。
【讨论】: