1
votes

these are just the methods i can override during animationListener. http://developer.android.com/reference/android/view/animation/Animation.AnimationListener.html

Animation animation

animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.device_box);

animation.setAnimationListener(new AnimationListener(){
        @Overridepublic void onAnimationEnd(Animation arg0) {}
        @Override public void onAnimationRepeat(Animation animation) {}
        @Override public void onAnimationStart(Animation animation) {}});

I think adding a thread in onAnimationStart and stop it on onAnimationEnd and getting the coordinates with a loop inside the thread, this may work. But i think that i could get some problems with buttons because, when animating them in this way, only the background moves, not button area itself

In this case, i have to investigate more with buttons

What do you think about this, is there another way to achieve what i want?
Is this the better way to do it ?

1
I think the problem is how you define your animation. Please show the code of this: Animation animation = new ??? - Nguyễn Hoài Nam

1 Answers

0
votes

I researched, and what I got is this, not X and Y but can handle the data as get what has been animated as time.

                 ObjectAnimator anim = ObjectAnimator.ofFloat(box_image, "translationX", 0 , cant);

                  anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                                @Override
                                public void onAnimationUpdate(ValueAnimator arg0) {

                                  double f = Math.round(arg0.getAnimatedFraction()*1000.0)/1000.0;
                                    Log.d("datos", ""+f);
                                }
                            });
                  anim.setDuration(1000);
                  anim.start();