如何画在画布上的文字? [英] How to draw text on canvas?

查看:332
本文介绍了如何画在画布上的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图开发一个简单的饼图类机器人。现在,它可以利用标签和值的地图,绘制饼图。我还没有添加传奇的馅饼,这是我需要的地方附近小矩形文本在屏幕角落。任何帮助AP preciated,因为我是新来的Andr​​oid开发人员。谢谢你。

i'm trying to develop a simple pie chart class for android. For now, it can take a map of labels and values and draw the pie chart. I'm yet to add the legends for the pie, which is where i need to place the texts near small rectangles on the screen corner. Any help appreciated, since i'm new to Android dev. Thanks.

推荐答案

您必须使用Canvas类的方法的drawText

You will have to use the drawText method of the Canvas class.

Paint paint = new Paint(); 
canvas.drawPaint(paint); 
paint.setColor(Color.BLACK); 
paint.setTextSize(16); 
canvas.drawText("My Text", x, y, paint); 

下面是关于它的相关文件:

Here's the relevant documentation about it:

<一个href="http://developer.android.com/reference/android/graphics/Canvas.html#drawText%28java.lang.String,%20float,%20float,%20android.graphics.Paint%29">http://developer.android.com/reference/android/graphics/Canvas.html#drawText(java.lang.String,浮球,浮球,android.graphics.Paint)

这篇关于如何画在画布上的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆