hi i'm work on animation(using TranslateAnimation()) i have 4 button(left move,right move,up button,down button) and a imageview i want now how can save the new position when the animation is ended,and run another animation starting from the new position
Asked
Active
Viewed 433 times
1 Answers
0
On the animation call the method setFillAfter(true)

bogdan
- 782
- 3
- 7
-
i'have already try with animation.setFillEnabled(true); animation.setFillAfter(true); but for example i press 2 times the right button the the image is duplicated – Keyren May 15 '13 at 12:01
-
I must correct the image is duplicated only in the directions down and right – Keyren May 15 '13 at 12:15
-
`private OnClickListener click_Dx = new OnClickListener() { @Override public void onClick(View v) { animation = new TranslateAnimation(0,50,0,0); animation.setDuration(2000); animation.setRepeatCount(0); IMG3.setImageDrawable(getResources().getDrawable(R.drawable.dx)); IMG3.setAnimation(animation); animation.setFillEnabled(true); animation.setFillAfter(true); } };` for each clickListener, the image moves in one direction, they are all the same so I write only one – Keyren May 15 '13 at 12:41
-
What is the sdk minimum target for the project? If it is 3.0 or higher you should use `ObjectAnimator`, it is working a lot better, the `TranslateAnimation` only changes the position displayed on the screen, but the layout position stays the same, that is why the second time the translation isn't working well, from the version 3.0 the `ObjectAnimator` was introduced and it is working better. – bogdan May 15 '13 at 13:01
-
the min sdk is 8 but I can change it if you do need =) anyway how work ObjectAnimator? – Keyren May 15 '13 at 13:14
-
http://stackoverflow.com/questions/10854940/android-using-objectanimator-to-translate-a-view-with-fractional-values-of-the – bogdan May 15 '13 at 13:35
-
http://www.techrepublic.com/blog/app-builder/create-slick-transitions-with-androids-objectanimator-class/2052 – bogdan May 15 '13 at 13:36
-
I had a look, and actually looks better than the simple TranslateAnimation, but as I solve my problem, it will also be more comprehensive, but at the time I did not understand very xD I focused on the example of the second link you gave me,for set the rotation using this syntax `ObjectAnimator scaleXOut = ObjectAnimator.ofFloat(tv, "scaleX", 1f, 0f);` What are those numbers with 'f'?(1f,0f ecc..) – Keyren May 15 '13 at 14:28
-
"f" comes from float, if you use just 1 or 0 this are integer values, but if you specify f they will be float values – bogdan May 15 '13 at 14:33
-
oh i see thanks^^ and if I wanted to move the image to the right for example how would I go about it? I'm editing the code in and I managed to get other effects particoli, but I can not move to the word to the right – Keyren May 15 '13 at 14:51