(Android) Doubt 'Canvas.drawText' [closed]

0

Good morning, I would like to show a text, (especially letters), on my canvas. The idea is that whenever you call the oncliklistener of the view, a letter will be displayed on the screen.

I've seen that it could work with 'Canvas.drawText' Any ideas?

    
asked by PiledroMurcia 15.05.2017 в 08:28
source

1 answer

0

Is that what you're looking for? With the method fillText()

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
Your browser does not support the canvas element.
</canvas>

<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Texto",10,50);
</script>

</body>
</html>

With the drawText() method that you mentioned:

Paint paint = new Paint(); 
paint.setColor(Color.WHITE); 
paint.setStyle(Style.FILL); 
canvas.drawPaint(paint); 

paint.setColor(Color.BLACK); 
paint.setTextSize(20); 
canvas.drawText("Texto", 10, 25, paint); 
    
answered by 15.05.2017 / 08:52
source