在将每个字母绘制到画布之前,是否有可用于为每个字母设置动画的解决方案???我搜索互联网,我似乎没有看到任何合理的......
private void draw() {
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
// Draw background
canvas.drawColor(PrefService.getBgColor());
StaticLayout textLayout = new StaticLayout(TEXT_I_WOULD_LIKE_TO_ANIMATE, textPaint, screenWidth - screenWidth / 8, Layout.Alignment.ALIGN_CENTER, 1.0F, 1.0F, true);
canvas.translate((screenWidth / 2) - (textLayout.getWidth() / 2), (screenHeight / 2) - ((textLayout.getHeight() / 2)));
textLayout.draw(canvas);
}
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
}
handler.removeCallbacks(drawRunner);
handler.postDelayed(drawRunner, 20000);
}
注意StaticLayout上面的TEXT_I_WOULD_LIKE_TO_ANIMATE变量
任何帮助非常感谢
答案 0 :(得分:0)
创建渲染线程,循环绘制方法。然后,您可以为文本变量创建位置,并更改每个帧的文本位置。要在画布上绘制文本,您应该使用canvas.drawText(...)。 我希望我能帮到你。