Wednesday, September 25, 2013

[android help] Start simple Animation top to bottom from a specific position


Start simple Animation top to bottom from a specific position


android - Start simple Animation top to bottom from a specific position - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















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.


























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 :)




















default






Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...