java - 安卓 : Get new position of View after animation

标签 java android

动画后如何获得新的 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/

相关文章:

android - NotificationCompat2 错误 : java. lang.IllegalArgumentException

android - 如何确定屏幕上的软按钮android

java - Firebase 数据库异常无法将 long 转换为 String

Java while 循环 | true 如果测试值返回异常错误

Java 不会读取 Node.js 服务器

java - 尝试在Java中使用xlsx读取并返回字符串数组

android - 使用新的 Material Design 在 AppBarLayout 上方叠加内容

javascript - firebase证书对象必须包含字符串 "private_key"属性

Java - 将管道分隔文本\csv 文件转换为 XML

java - 如何限制动态查询只接受 select 语句?