I need to make a textview that perform an animation from top to bottom and the animation start with the y value 50. How to do it? Thanks in advance.
Asked
Active
Viewed 511 times
1 Answers
0
You can use TranslateAnimation. TranslateAnimation uses deltas, so to calculate the position of 50px from the top of the screen, subtract the top of the view & add 50. In this example, I set the toY by adding some value to the fromY. Here's the code:
int fromY = 50 - view.getTop();
int toY = fromY + someValue;
TranslateAnimation animation = new TranslateAnimation(0, 0, fromY, toY);
animation.setDuration(someDuration);
view.startAnimation(animation);
Hope this helps :)

Gil Moshayof
- 16,633
- 4
- 47
- 58
-
yes your logic is absolutely right. since i have the view height only 150dp so if i add toY then it come down the back to its position. I remove only that. n it work for my code. thank u. :) – swati srivastav Sep 25 '13 at 09:43