动画后如何获得新的 View 位置?
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 何时接近另一个 View 。
我该如何检查?
动画后如何获得新的 X 和 Y 或高度和宽度?
我试图让它们进入 onAnimationEnd ,但它是静态值,动画结束后不会改变..
对不起语法
最佳答案
尝试 getLocationOnScreen 方法。
int[] locationOnScreent = new int[2];
yourView.getLocationOnScreen(locationOnScreent);
// locationOnScreent[0] = x
// locationOnScreent[1] = y
关于java - 安卓 : Get new position of View after animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27528466/