Java – Android UI element animation
•
Java
I'm trying to animate UI elements I want to move an EditText and a button from the middle of the screen and display the result of an HTTP call in the table It would be great if someone could point me in the right direction. At this time, I don't know if I should use Java or XML
Thank you in advance
Solution
The translation framework is used to achieve this. Its working principle is as follows:
TranslateAnimation(float fromXDelta,float toXDelta,float fromYDelta,float toYDelta)
Therefore, you need to write code to move the view in the y-axis direction, as follows:
mAnimation = new TranslateAnimation(0,599); mAnimation.setDuration(10000); mAnimation.setFillAfter(true); mAnimation.setRepeatCount(-1); mAnimation.setRepeatMode(Animation.REVERSE); view.setAnimation(mAnimation);
The view here can be anything, textview, ImageView, etc
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码