Android的Canvas.drawText [英] Android Canvas.drawText
本文介绍了Android的Canvas.drawText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个观点,我跟在OnDraw中(画布油画)方法Canvas对象绘制。我的code是:
I have a view, I'm drawing with the Canvas object in the onDraw(Canvas canvas) method. My code is:
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Style.FILL);
canvas.drawPaint(paint);
paint.setColor(android.R.color.black);
paint.setTextSize(20);
canvas.drawText("Some Text", 10, 25, paint);
问题是,文本不通过后台显示,我究竟做错了什么?如果我删除canvas.drawPaint(油漆)和paint.setColor(android.R.color.black),你可以看到屏幕上的文字......
The problem is the text doesn't show through the background, what am I doing wrong? If I remove the canvas.drawPaint(paint) and paint.setColor(android.R.color.black) you can see the text on the screen.....
推荐答案
曾为这一点,事实证明,android.R.color.black是不一样的Color.BLACK。改变了code到:
Worked this out, turns out that android.R.color.black is not the same as Color.BLACK. Changed the code to:
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Style.FILL);
canvas.drawPaint(paint);
paint.setColor(Color.BLACK);
paint.setTextSize(20);
canvas.drawText("Some Text", 10, 25, paint);
和这一切工作正常现在!
and it all works fine now!!
这篇关于Android的Canvas.drawText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文