Use SpannableString to implement a small load animation
It is still a github open source project: WaitingDots This project does not have many codes, and the implementation is very simple, but it is very interesting because the basic elements of animation are not drawn, but are implemented using spannableString. DotsTextView.java JumpingSpan.java MainActivity.java DotstextView is the main body of animation. JumpingSpan is a basic element and a plug-in in animation. In MainActivity, you only need to introduce DotsTextView in the layout. The following is the dividing line, show code: package pl.tajchert.sample; import android. graphics. Canvas; import android. graphics. Paint; import android.graphics.Paint.FontMetricsInt; import android.text.style.ReplacementSpan; /* ReplacementSpan is really a magical thing, and it is rarely introduced on the official api * Several main functions are also do nothing. * In this example, the custom translationX and translationY have no effect . If you assign values to two variables *, the distance between the first JumpingSpan and the previous element will increase. This is used here to make each “.” a separate unit for independent operations */ public class JumpingSpan extends ReplacementSpan { private float translateOnX= 0; private float translateOnY= 0; @Override public int getSize(Paint paint, CharSequence text, int start, int end, FontMetricsInt fontMetricsInt) { return (int) paint.measureText(text, start, end); }…