我尝试使用 canvas.rotate() 方法使文本垂直。但是在 android 4.0 - 4.1 上我得到了一个“跳舞的字母”,见截图。发生了什么事,我该如何解决?请帮助我。
4.0 - 4.1 结果:
正常结果:
这是代码
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint textPaint = new Paint();
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(30);
canvas.rotate(90);
canvas.drawText(text, 0, -getWidth()/2, textPaint);
canvas.save();
canvas.restore();
}
最佳答案
简单地说,您可以尝试一下并且:
使用 textView
并在其上设置 rotateAnimate
和 setDuration
最小值并设置 setFillAfter(true)
如下所示:
RotateAnimation rt = new RotateAnimation(0, 90,textView.getLayoutParams().width/2,textView.getLayoutParams().height/2);
rt.setDuration(1);
rt.setFillAfter(true);
textView.startAnimation(rt);
很简单
关于android - 应用于文本的方法 canvas.rotate(90) 对于 android 4.0-4.1 已损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14379909/