【发布时间】:2018-03-21 05:47:22
【问题描述】:
动画后如何获得新的视图位置?
if(animationCompeleted == 1)
{
return;
}
if(animationCounter != 0)
{
this.width = this.width + 1.f;
this.heigh = this.heigh + 1.f;
}
final ScaleAnimation scale = new ScaleAnimation(this.width, this.width + 1.0f, this.heigh, this.heigh + 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
scale.setDuration(1000);
scale.setFillAfter(true);
scale.setFillEnabled(true);
scale.setAnimationListener(new Animation.AnimationListener()
{
@Override
public void onAnimationStart(Animation arg0)
{
animationCompeleted = 1;
animationCounter++;
}
@Override
public void onAnimationRepeat(Animation arg0)
{
animationCompeleted = 2;
}
@Override
public void onAnimationEnd(Animation arg0)
{
animationCompeleted = 2;
//I want to get new position of imageView for comparing with another view(detection going-on it)
}
});
imageView.startAnimation(scale);
我想知道我的 imageView 何时靠近另一个视图。
怎么查?
如何在动画后获得新的 X 和 Y 或高度和宽度?
我想让它们进入 onAnimationEnd ,但它是静态值,动画结束后它不会改变..
对不起语法
【问题讨论】:
-
onAnimationEnd():View.getX()&View.getY()不起作用? -
这个值在动画后没有改变,我在动画前后得到相同的值
-
哇,这违反直觉。你能在动画开始之前计算 newX 和 newY 吗?
-
我没试过,也不知道该怎么做