Android Translate Animation

I have an ImageView that is 250dp above the bottom, and with the translation of the animation I want to move it 50dp above the bottom.

I know how to use translational animation, but I don’t know what the ToYValue field was.

The wil code would be something like this:

TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT,0,Animation.ABSOLUTE,250,Animation.ABSOLUTE,50);
translate.setDuration(1000);
translate.reset();  
translate.setFillAfter(true);
iv.clearAnimation();
iv.startAnimation(translate);
+5
source share
1 answer

You want to get from YValue from 0, that is, start from where it is currently and toYValue from 50, which means moving 50 pixels down. Note that these values ​​are in pixels, not dp. If it should be in dp, this is another question ..

The key is in the word "change" from the TranslationAnimation documentation "Changing the Y coordinate for use at the beginning of the animation."

http://developer.android.com/reference/android/view/animation/TranslateAnimation.html

+2

All Articles