Beautiful Animated NumberTextView extracted from Telegram source code
Add a copy of NumberTextView.java in your project.
Define the NumberTextView
in XML (or you can define it in activity without using XML):
<.... NumberTextView
android:id="@+id/numberTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Then:
final NumberTextView numberTextView = findViewById(R.id.numberTextView);
numberTextView.setTextSize(28);
numberTextView.setTextColor(Color.RED);
numberTextView.setTextAlignment(TEXT_ALIGNMENT_CENTER);
//numberTextView.setTypeface(Typeface.SANS_SERIF);
int counter = 0;
button.setOnClickListener(v -> {
binding.numberTextView.setNumber(counter, true, false);
counter++;
});
That's it!