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. B4A Code Snippet [B4X] [XUI] Accurate Text Measurement and Drawing - Erel (first post)    May 10, 2018   (2 reactions) Note that it is not possible to accurately draw a border around text, like done in this example, with the standard Canvas.MeasureStringHeight method as it only returns the total height and lacks the height above baseline.
This is a good point. In B4J and B4i you can call this method without initia Bug? Canvas measurestringwidth problem - Nikan99    Apr 28, 2023 So I create a background of every label as much as its text is. That works perfectly.
If beforebtnslength > Activity.Width Then
ycounter = ycounter + 1
beforebtnslength = 0
Else If beforebtnslength + SQLReader.GetString("name").Length*3%x > Activity.Width Then
ycounter = ycounter + 1 B4A Question MeasureStringHeight - Sergey_New    Mar 02, 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 must be doubled.
Does it depend on the screen settings?
How to do it right? 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.DEF Spanish Altura de Label y TextField - TILogistic (first post)    Apr 19, 2024 2dip)
Private cvs As Canvas
cvs.Initialize2(bmp)
Return cvs.MeasureStringHeight(Text, Font1.ToNativeFont, Font1.Size)
#Else If B4i
Return Text.MeasureHeight(Font1.ToNativeFont)
#Else If B4J
Dim jo As JavaObject
jo.InitializeNewInstance("javafx.scene.text.Text", Array(Text))
B4A Question Max Text Size - RandomCoder (first post)    May 29, 2015   (2 reactions) Hi @klaus there are no layout parameters. The point I was trying to make was that I was creating the views in code not the designer (see post #1). If the view is wider than it is tall then all works correctly using Canvas.MeasureStringWidth but if the view is taller than it is wide then the text is B4A Question [Solved] StateListDrawable with B4XPages - klaus (first post)    Jul 21, 2024   (3 reactions) Now seeing the code I found the problem. In the Ideal_Text_Size method a Canvas is assigned to the Button, and this new assignment overrides the StateListDrawable definition. If you modify the Ideal_Text_Size method like below, commenting all lines concerned by the Canvas the Buttons behave as expec B4A Question webview in tabhost - PrzemekBoa (first post)    Apr 03, 2019 Canvas.MeasureStringHeight("M", Typeface.DEFAULT_BOLD, PD.LegendTextSize) For i = 0 To PD.Items.Size - 1 Dim it As PieItem it = PD.Items.Get(i) textWidth = Max(textWidth, PD.Canvas.MeasureStringWidth(it.Name, Typeface.DEFAULT_BOLD, PD.LegendTextSize)) Next bmp.Ini B4A Question set label height based on its text length - ronell (first post)    May 12, 2018   (1 reaction) why are you using MeasureStringHeight if you want to set label based on its length?
try changing your code to this
itmheight = Canvas1.MeasureStringWidth(msggtext, Typeface.DEFAULT, globalfontsize) Page: 1   2   3   4   5   6   7   Powered by ColBERT |