重写onDraw,绘制文本
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawText(drawText, 0, progress, getWidth() / 2 - widthText / 2, getHeight() / 2, paint);
}
添加属性动画
ObjectAnimator an = ObjectAnimator.ofInt(view, "progress", 0, drawText.length());
an.setStartDelay(1000);
an.setDuration(2000);
an.start();
没错,就是如此简单