Hi All,
I am trying to find a Chr.width with B4XCanvas in order to set the text size of an edittext correctly. [nothing new.]
With Canvas this is basically the code I have used in the past.
... and then through a loop adjust the font size to match the edittext.
In B4XPages using B4XCanvas I don't have a "FontSize" parameter. In searching a few examples what is done in respect of FontSize escapes me.
Somewhere the size of the font is included, any hints would be great.
Regards Roger
I am trying to find a Chr.width with B4XCanvas in order to set the text size of an edittext correctly. [nothing new.]
With Canvas this is basically the code I have used in the past.
B4X:
Private Canvas1 As Canvas
Canvas1.Initialize(Activity)
fontsize as Float = 26
chrwidth as Float
chrwidth = Canvas1.MeasureStringWidth("9", Typeface.DEFAULT, fontsize)
... and then through a loop adjust the font size to match the edittext.
In B4XPages using B4XCanvas I don't have a "FontSize" parameter. In searching a few examples what is done in respect of FontSize escapes me.
B4X:
Private Canvas1 As B4XCanvas
Private ChrRect As B4XRect
fontsize as Float = 26
chrwidth as Float
Canvas1.Resize(Panel1.width, Panel1.height)
ChrRect = B4XCanvas1.MeasureText("9", Typeface.DEFAULT)
ChrWidth = ChrRect.Width
Somewhere the size of the font is included, any hints would be great.
Regards Roger