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.
source share