Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd and manage a layer over a canvas using SurfaceView
    text
    copied!<p>I want to say that maybe (probably) the word 'layer' is not the correct one, but I believe it gives the correct idea of what I want to do.</p> <p>I am using a SurfaceView wich implements SurfaceHolder.Callback.</p> <p>I am working on a canvas. I am drawing a quite complex set of points. I have the canvas translated, rotated and scaled (translateX and translateY are variable that changes when the user interacts with the canvas):</p> <pre><code>canvas.translate(0, 0); canvas.rotate(-90); canvas.translate(translateX, translateY); canvas.scale(scaleX, scaleY); </code></pre> <p>My next step is to add text and images on top of this canvas. Both the text and the images should not be scaled nor rotated, only translated (they should follow the canvas).</p> <p>For this reason I was thinking about having some sort of 'layer' or something similar transparent which only follows the canvas movements and does not change on zoom in or zoom out or on rotation [think them as some sort of UI which stay over the whole canvas].</p> <p>Thanks in advance.</p> <p>N.</p> <p><strong>EDIT:</strong></p> <p>Here is a snippet: </p> <pre><code> @Override public void onDraw(Canvas canvas) { try{ pt.setColor(Color.BLACK); canvas.drawColor(Color.WHITE); canvas.drawText("HELLOOOOOOOOOOOOOOOO", 100, 10, pt); pt.setAntiAlias(true); canvas.save(); canvas.rotate(-90, 0, 0); canvas.drawText("HELLOOOOOOOOOOOOOOOO", getHeight(), 10, pt); canvas.restore(); } catch(Exception e) {} } </code></pre> <p>I want the two 'HELLOOOOOO' to appear close to each other. I cant figure out how to...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload