Android ui element animation

I am trying to animate user interface elements. I would like to move the editText and button from the middle to the top of the screen and display the results of the http call below them in the table. It would be great if someone could point me in the right direction, at the moment I do not know what I should use Java or XML for this.

Thanks in advance.

+6
source share
2 answers

To achieve this, use the Translation Framework interface, which works like:

TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

So, you need to write your code to move in the y direction, as shown below:

  mAnimation = new TranslateAnimation(0, 0, 0, 599); mAnimation.setDuration(10000); mAnimation.setFillAfter(true); mAnimation.setRepeatCount(-1); mAnimation.setRepeatMode(Animation.REVERSE); view.setAnimation(mAnimation); 

Here the view can be any, textview, imageView, etc.

+8
source

the accepted answer caused an error inside my code, the code fragment below is almost identical to the accepted answer and worked without errors to move the object off the screen. I need gestures attached to keyPad to also β€œshift”, and switched from TranslateAnimation to ObjectAnimator (second block of code below).

 final LinearLayout keyPad = (LinearLayout)findViewById(R.id.keyPad); moveKeyPadUp(keyPad); private void moveKeyPadUp(LinearLayout keyPad){ Animation animation = new TranslateAnimation(0,0,0,-500); animation.setDuration(1000); animation.setFillAfter(true); keyPad.startAnimation(animation); } private void moveKeyPadUpdated(LinearLayout keyPad){ ObjectAnimator mover = ObjectAnimator.ofFloat(keyPad,"translationY",0,-500); mover.setDuration(300); mover.start(); } 
+1
source

Source: https://habr.com/ru/post/907761/


All Articles