public class MainActivity extends AppCompatActivity {
private String[] dotText = {" . ", " . . ", " . . ."};
ValueAnimator valueAnimator;
private TextView dotView;
private String loadingTxt = "加载中";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dotView = (TextView) findViewById(R.id.dot_view);
if (valueAnimator == null) {
valueAnimator = ValueAnimator.ofInt(0, 3).setDuration(1000);
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int i = (int) animation.getAnimatedValue();
dotView.setText(loadingTxt + dotText[i % dotText.length]);
}
});
}
valueAnimator.start();
}
}
加载中... 后面三个点动画实现方案
最新推荐文章于 2024-06-07 11:15:24 发布