There is a view in which I want to write text on the canvas.
First, I set the text size in paint be equal to the height of the view, and then maybe I make a mistake, I do not understand:
this.fontSize = getHeight(); this.paint.setTextSize(fontSize); Rect textBounds = new Rect(); this.paint.getTextBounds(myText, 0, myText.length(), textBounds); Then I draw the text:
canvas.drawText( myText, canvas.getWidth() - textBounds.width(), canvas.getClipBounds().top + textBounds.height(), paint); But the text is higher in height than the view itself. I bring in logs:
fontSize = 32 textBounds.height() = 22 The question is how to set the size of the text so that it would be the same size in height as the view itself?