Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text height and width separately when drawing with canvas

I want to know if there is any way to modify text height and width separately when drawing with canvas. To set text size you can simply do paint.setTextSize(x);but it change text size in X and Y and I need to change text size in X and Y separately as you do with paint.setTextScaleX(x);but there isn't anything like paint.setTextScaleY(y);.

Is any way to implement this or does it already exists in Android ?

Thank you

like image 852
Andres Avatar asked Dec 12 '12 00:12

Andres


1 Answers

There is no setTextScaleY method, because there is no need for one. setTextSize multiplies both X and Y scale factors, and setTextScaleX multiplies the X scale factor only. So you could reach any desired scaling scaleX, scaleY this way:

setTextSize(scaleY);
setTextScaleX(scaleX/scaleY); //setTextScaleX scales according to the CURRENT size (setTextScaleX(1) does nothing).
like image 82
Jong Avatar answered Oct 23 '22 13:10

Jong