M Mark Stuart Well-Known Member Licensed User Longtime User Feb 19, 2021 #1 How do you set the height of a Label node, in code, to the height (width is set and cannot change) that will show all content of the label? I've tried setting the Label.Height and Label.PrefHeight to no avail. I'm trying to use this with the JFXPrint8 library. Thanx, Mark Stuart
How do you set the height of a Label node, in code, to the height (width is set and cannot change) that will show all content of the label? I've tried setting the Label.Height and Label.PrefHeight to no avail. I'm trying to use this with the JFXPrint8 library. Thanx, Mark Stuart
William Lancee Well-Known Member Licensed User Longtime User Feb 20, 2021 #2 Start by setting Private xui as XUI in Process_Globals (add XUI as library) With B4XView you have much better control of the dimensions of a label. With B4Xcanvas you can get the exact height of text. Typically: B4X: Copy Dim cv As B4XCanvas 'ignore, this doesn't need to be initialized for this purpose Dim alablx As B4XView = alabl 'alabl created with designer or in code' alablx.Text = "XXXX" alablx.Height = 2 * cv.MeasureText(alablx.Text, alablx.font).Height Upvote 0
Start by setting Private xui as XUI in Process_Globals (add XUI as library) With B4XView you have much better control of the dimensions of a label. With B4Xcanvas you can get the exact height of text. Typically: B4X: Copy Dim cv As B4XCanvas 'ignore, this doesn't need to be initialized for this purpose Dim alablx As B4XView = alabl 'alabl created with designer or in code' alablx.Text = "XXXX" alablx.Height = 2 * cv.MeasureText(alablx.Text, alablx.font).Height