Android: text animation

I work in android .. I want to move my text in the animation.

this is the xml code I'm using: -

android:shareInterpolator="true"> <translate android:fromXDelta="0%p" android:toXDelta="-80%p" android:fromYDelta="0%p" android:toYDelta="0%p" android:duration="2000" /> 

  android:pivotX="-70%p" android:pivotY="10%p" android:duration="1000" android:startOffset="2000" /> 

 android:fromXDelta="0%p" android:toXDelta="80%p" android:fromYDelta="0%p" android:toYDelta="0%p" android:duration="2000" android:startOffset="3000" /> 

Using the above xml my TEXT moves in this form: - enter image description here

But I want to move the text as follows: enter image description here

means I want to move my text to Z format. please suggest me how to write xml code for this. You can provide me some links for this. if you can do this, this will be a very big help for me.

Thanks in advance.

+4
source share
2 answers

the following works for me:

 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:shareInterpolator="true"> <translate android:fromXDelta="0%" android:toXDelta="80%p" android:fromYDelta="0%" android:toYDelta="0%" android:duration="2000"/> <translate android:fromXDelta="0%" android:toXDelta="-80%p" android:fromYDelta="0%p" android:toYDelta="80%p" android:duration="1000" android:startOffset="2000"/> <translate android:fromXDelta="0%" android:toXDelta="80%p" android:fromYDelta="0%" android:toYDelta="0%" android:duration="2000" android:startOffset="3000"/> </set> 
+5
source

You can do this by following these steps.

1.create an .xml animation

2.Paste this code in this .xml animation

 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:shareInterpolator="true"> <translate android:fromXDelta="0%" android:toXDelta="80%p" android:fromYDelta="0%" android:toYDelta="0%" android:duration="2000"/> <translate android:fromXDelta="0%" android:toXDelta="-80%p" android:fromYDelta="0%p" android:toYDelta="80%p" android:duration="1000" android:startOffset="2000"/> <translate android:fromXDelta="0%" android:toXDelta="80%p" android:fromYDelta="0%" android:toYDelta="0%" android:duration="2000" android:startOffset="3000"/> </set> 

put this file in the res / anim folder of your application.

write the following code for your text view on which you want to make an animation.

  Animation animation = AnimationUtils.loadAnimation(this,R.anim.animation); animation.setAnimationListener(this); View animatedView = findViewById(R.id.textview); animatedView.startAnimation(animation); 

Hope you can easily understand that now.

+5
source

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


All Articles