1

I have a Drawable object, and I want to find the absolute coordinates in the screen. All the functions I found were related to the relative coordinates and not the absolute.

Here is the code:

public class MainActivity extends Activity {

AnimationDrawable rocketAnimation;
int counter = 0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView rocketImage = (ImageView) findViewById(R.id.ball_laugh);
    rocketImage.setBackgroundResource(R.drawable.frames);
    rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
    rocketAnimation.start()
}

public boolean onTouchEvent(MotionEvent event) {
      if (event.getAction() == MotionEvent.ACTION_DOWN) {

         // Get the frame of the animation
         Drawable currentFrame;
         currentFrame = rocketAnimation.getCurrent();

         // Now I want to get the x,y coordinates of currentFrame..   

        return true;
      }
      return super.onTouchEvent(event);
    }
}
ZygD
  • 22,092
  • 39
  • 79
  • 102
1337
  • 317
  • 1
  • 9

0 Answers0