Canvas. MeasureStringHeight (Text As String, Typeface As android.graphics.Typeface, TextSize As Float) As FloatReturns the height of the given text.Example of drawing a blue text with white rectangle as the background: Dim Rect1 As Rect Dim width, height As Float Dim t As String t = "Text to write" width = Canvas1.MeasureStringWidth(t, Typeface.DEFAULT, 14) height = Canvas1.MeasureStringHeight(t, Typeface.DEFAULT, 14) Rect1.Initialize(100dip, 100dip, 100dip + width, 100dip + height) Canvas1.DrawRect(Rect1, Colors.White, True, 0) Canvas1.DrawText(t, Rect1.Left, Rect1.Bottom, Typeface.DEFAULT, 14, Colors.Blue, "LEFT") Wish PdfDocument - Allow Canvas Measuring without StartPage - Robert Valentino    Feb 27, 2019 Private mPDF As PdfDocument mPDF.Initialize mPDF.StartPage(mPageSize.Width, mPageSize.Height) TextHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString, mFont_Roboto_Regular, (10 / mScale)) SubHeadingHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString... you can MeasureStringHeight or MeasureStringWidth Normally I measure my Header items to determine where I want to... B4A Question Max Text Size - RandomCoder    May 26, 2015 it works correctly but if smaller then the textsize is too large even though the canvas MeasureStringHeight suggests that it should fit?
I've thrown together a small sample (attached), and the code...)
' Set canvas and initialise text size to try
Dim c As Canvas
c.Initialize(v)
Dim...)
Dim fltH As Float = c.MeasureStringHeight(str, Typeface.DEFAULT_BOLD, fltSize)
' Check... B4A Question Question about text size - klaus (first post)    Nov 7, 2015 Canvas.MeasureStringHeight(Text As String, Typeface As Typeface, TextSize As Float)
Returns : Float... B4A Question Canvas.DrawText Positioning issue/formula - RandomCoder (first post)    Jun 22, 2015 I'm pretty sure that the problem will be with the Canvas.MeasureStringHeight it is not reliable. Erel advised me in a previous post somewhere on the Forum to use StringUtils instead.... B4A Question Canvas Draw Text Center Is Not Centering - Jeffrey Cameron (first post)    Jun 22, 2018   (2 reactions) add 1/2 of the text height to your Y value (see Canvas.MeasureStringHeight).... B4A Question Resize Label text with Java Object - klaus (first post)    May 21, 2015   (1 reaction) Unfortunately your code will not work in all cases because Canvas1.MeasureStringHeight returns different values depending on the text.
Example:
Canvas1.MeasureStringHeight("a", Typeface.DEFAULT, 16)
Canvas1.MeasureStringHeight("A", Typeface.DEFAULT, 16)
Canvas1.MeasureStringHeight("Aj", Typeface.DEFAULT, 16)
These three statements return different values !
The factor... B4A Question MeasureStringHeight - Sergey_New    Mar 2, 2024 To set the label height I use this code
Dim cn As Canvas
cn.Initialize(Activity)
lbl.Height=cn.MeasureStringHeight("T", Typeface.DEFAULT,14)
To display correctly, the height of the label... B4A Question DB to text for pdfcreate - harinder (first post)    Dec 29, 2020 )
yoff = yoff + pdf.Canvas.MeasureStringHeight(outputstr, Typeface.DEFAULT_BOLD, 30...("green")} ${rs.getstring("blue")}"$
pdf.Canvas.DrawText(outputstr, 250, 150... B4A Question Listview label height - LucaMs (first post)    Mar 31, 2014 damn... and canvas MeasureStringHeight also don't calculates the text height as i need.
Thanks for you help.... B4A Question fontsize multiple layout - Erel (first post)    May 28, 2015   (1 reaction) Canvas.MeasureStringHeight is based on a lower level API that doesn't behave in the same way that a Label or EditText will behave. StringUtils uses the same measurement process as the views.... Page: 1   2   3   4   5   6   7   |