Canvas. MeasureStringWidth (Text As String, Typeface As android.graphics.Typeface, TextSize As Float) As FloatReturns the width 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") B4A Question Canvas.MeasureStringWidth - ykucuk    Oct 16, 2017 Hi
Canvas.MeasureStringWidth doesn't work when text is long or include CRLF
Any help?... Bug? Canvas measurestringwidth problem - Nikan99    Apr 28, 2023 is canvas'
cvsTest.Initialize(btn)
btn.Height = cvsTest.MeasureStringHeight(btnText, Typeface.DEFAULT, 40)
btn.Width = cvsTest.MeasureStringWidth(btnText, Typeface.DEFAULT, 30) + 10dip... using a canvas to measure its text. So I create a background of every label as much as its text... Bug? canvas.MeasureStringWidth return wrong value - ArminKH    Feb 9, 2015 hi erel
i think some times canvas return wrong values for MeasureStringWidth
i think when the text... measure string width by using reflection or other tools?
tnx erel... B4A Question Canvas MeasureStringWidth Android 1.6 - stevel05    Nov 24, 2011 I attach a small project that demonstrates an issue with Canvas.MeasureStringWidth, this appears to only be an issue on Android 1.6 (on the emulator at least) And only on the Sans Serif font (Which is also the default font). I don't have a real 1.6 device to test it on so I was hoping some kind soul would be able to test it. I've found the problem with lowercase a,e,i,r,f,g and... (first white box) and the red line on the label shows the Canvas.MeasureString Width value... B4A Question [Solved by Klaus] 9Patch and MeasureStringWidth - LucaMs    Jun 20, 2019 If there a "conflict" between 9Patch and canvas MeasureStringWidth or, as always :D, I'm doing something wrong?
If I use canvas MeasureStringWidth after applying the 9 patch I get a strange result (see the attached project, please).... B4A Question MeasureStringWidth with csBuilder - Erel (first post)    Mar 26, 2019 Canvas.MeasureStringWidth expects a string, not a CharSequence (CSBuilder). It will ignore the string attributes. I guess that the simplest solution will be to add a small gap as a compensation for this.... B4A Question pdf.Canvas.DrawText - Giusy (first post)    Mar 15, 2019 You can measure the length of the string with Canvas.MeasureStringWidth(Text As String, Typeface As Typeface, TextSize As Float).
And if the length is wider than the page width split it and write the rest onto the next line.
Yes, I used Canvas.MeasureStringWidth(Text As String, Typeface As Typeface, TextSize As Float)
but what it means to use "split"... B4A Question Measure Multiline Text width - KZero    Jun 20, 2019 Hi, I know about Canvas.MeasureStringWidth, but it returns the string width ignoring line feeds any other ways to measure "Multiline" text width?... B4A Question problem of resizing with a panel - Erel (first post)    Aug 26, 2018 You can use Canvas.MeasureStringWidth to find the required width.... B4A Question font size when user sets big fonts in global settings - Erel (first post)    Sep 3, 2018 - Make the views a bit larger. - Resize the views based on the string size. Use Canvas.MeasureStringWidth to find the required size. - Accept the fact that some of the text will be truncated.... Page: 1   2   3   4   5   6   7   |