How to create Typing Animation in Android Studio
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<!--Code From Learnoset - Learn Coding Online.-->
<!--Download Learnoset App from PlayStore to learn coding,projects-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:hint="Enter Text"
android:id="@+id/animateTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/animateBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Animate Text" />
</LinearLayout>
MainActivity.java
/* Code From Learnoset - Learn Coding Online.*/
/* Download Learnoset App from PlayStore to learn coding,
* projects
*/
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
int count = 0;
private boolean isAnimating = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText animateEditText = findViewById(R.id.animateTxt);
final Button animateBtn = findViewById(R.id.animateBtn);
animateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isAnimating) {
isAnimating = true;
final String animateTxt = animateEditText.getText().toString();
animateEditText.setText("");
count = 0;
new CountDownTimer(animateTxt.length() * 100, 100) {
@Override
public void onTick(long millisUntilFinished) {
animateEditText.setText(animateEditText.getText().toString() + animateTxt.charAt(count));
count++;
}
@Override
public void onFinish() {
isAnimating = false;
}
}.start();
}
}
});
}
}
Projects with Source Code + Video Tutorials
You can download our Java and Android Studio Projects with Source Code and Video Tutorials.

Simple Music Player App (Version 2) for Android (Offline Version)

Login & Register Screen UI Design - 01

Login and Register Activity Material UI design in Android Studio
If you have any Questions or Queries
You can mail us at info.learnoset@gmail.com
Follow us to learn Coding and get in touch with new Technologies.