获取实时ImageView的坐标,而它在转换动画的android上 [英] Getting real time coordinates of ImageView while it is in Translate Animation on android

查看:255
本文介绍了获取实时ImageView的坐标,而它在转换动画的android上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ImageView的,集翻译动画。我希望当它移动的ImageView的实时坐标。

我的code位置:

  ImageView的MYIMAGE =(ImageView的)findViewById(R.id.myimage);  动画动画=新TranslateAnimation(100,200,300,400);
  animation.setDuration(1000);
  myimage.startAnimation(动画);
  animation.setRepeatCount(Animation.INFINITE);  INT X = myimage.getLeft();
  INT Y = myimage.getTop();

变量x和y不updatee实时只给了ImageView的原始静止坐标。

我怎样才能得到真正的时间坐标作为ImageView的是在运动?


解决方案

  INT [] = imageCordinates新INT [2];
                imgv1.getLocationOnScreen(imageCordinates);                X = imageCordinates [0] +(imgv1.getWidth()/ 2);
                Y = imageCordinates [1] +(imgv1.getHeight()/ 2);

I have an ImageView, set to Translate animation. I want real time coordinates of the ImageView when it is moving.

My code here:

ImageView myimage = (ImageView)findViewById(R.id.myimage);

  Animation animation = new TranslateAnimation(100, 200, 300, 400);
  animation.setDuration(1000);
  myimage.startAnimation(animation);
  animation.setRepeatCount(Animation.INFINITE);

  int x = myimage.getLeft();
  int y = myimage.getTop(); 

Variables x and y don't updatee real time and only give original static coordinate of the ImageView.

How can I get the real time coordinates as the ImageView is in motion ?

解决方案

int[] imageCordinates = new int[2];
                imgv1.getLocationOnScreen(imageCordinates);

                x = imageCordinates[0] + (imgv1.getWidth() / 2);
                y = imageCordinates[1] + (imgv1.getHeight() / 2);

这篇关于获取实时ImageView的坐标,而它在转换动画的android上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆