Android Sequential Text Animation example in Android
Android Text Animation Example
Sequential Animation on TextView
For that, Create a project in android studio and then create an anim directory under res directory and create an XML under anim directory.
In this, we create 10 type of animations on textviews.
- FadeIn
 - FadeOut
 - Blink
 - Rotate
 - Sequential
 - Bounce
 - Slide up
 - Slide Down
 - Move
 - Letter By Letter
 
Now, Firstly we create an Sequential XML file in our anim directory.
sequential.xml
 <set xmlns:android="https://schemas.android.com/apk/res/android"  
   android:fillAfter="true"  
   android:interpolator="@android:anim/linear_interpolator" >    
   <translate  
     android:duration="800"  
     android:fillAfter="true"  
     android:fromXDelta="0%p"  
     android:startOffset="300"  
     android:toXDelta="75%p" />  
   <translate  
     android:duration="800"  
     android:fillAfter="true"  
     android:fromYDelta="0%p"  
     android:startOffset="1100"  
     android:toYDelta="70%p" />  
   <translate  
     android:duration="800"  
     android:fillAfter="true"  
     android:fromXDelta="0%p"  
     android:startOffset="1900"  
     android:toXDelta="-75%p" />  
   <translate  
     android:duration="800"  
     android:fillAfter="true"  
     android:fromYDelta="0%p"  
     android:startOffset="2700"  
     android:toYDelta="-70%p" />  
   <rotate  
     android:duration="1000"  
     android:fromDegrees="0"  
     android:interpolator="@android:anim/cycle_interpolator"  
     android:pivotX="50%"  
     android:pivotY="50%"  
     android:startOffset="3800"  
     android:repeatCount="infinite"  
     android:repeatMode="restart"  
     android:toDegrees="360" />  
 </set>  
Then under Activitymain.xml create two TextView to show Sequential animation.
activity_main.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:app="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   tools:context=".MainActivity">  
 <LinearLayout  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:orientation="vertical"  
   android:gravity="center"  
   android:padding="15dp">  
 <TextView  
   android:layout_width="match_parent"  
   android:layout_height="wrap_content"  
   android:id="@+id/harpreet_text"  
   android:text="HARPREET"  
   android:gravity="center"  
   android:padding="15dp"  
   android:textSize="30dp"  
   android:fontFamily="cursive"  
   android:textColor="@color/colorPrimary"/>  
   <TextView  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:id="@+id/studio_text"  
     android:text="STUDIO"  
     android:gravity="center"  
     android:padding="15dp"  
     android:textSize="30dp"  
     android:fontFamily="cursive"  
     android:textColor="@color/colorPrimary"/>  
   </LinearLayout>  
 </RelativeLayout>  
Then under MainActivity.java your Animation is loaded automatically and after given time in handler it goes to NextActivity 
MainActivity.java
MainActivity.java
 public class MainActivity extends AppCompatActivity {  
 TextView harpreet_text,studio_text;  
 Animation sequential_anim;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     harpreet_text = findViewById(R.id.harpreet_text);  
     studio_text = findViewById(R.id.studio_text);  
     sequential_anim = AnimationUtils.loadAnimation(getApplicationContext(),  
         R.anim.sequential);  
     harpreet_text.startAnimation(sequential_anim);  
     studio_text.startAnimation(sequential_anim);  
     new Handler().postDelayed(new Runnable() {  
       @Override  
       public void run() {  
         Intent intent = new Intent(MainActivity.this, NextActivity.class);  
         startActivity(intent);  
         finish();  
       }  
     }, 5000);  
   }  
 }  
Then Create a new Activity called NextActivity which is opened when your animation finished.
After running your project, see Sequential animation on TextView.
Subscribe to Harpreet studio on Youtube
Like Harpreet Studio on Facebook
Follow me on Instagram
No comments