Routines to adjust a label to fit its text/adjust text size to fit a label:
* SizeToFitWidth - given a width (and using the label's font), adjust the label's height
* SizeToFitHeight - given a height (and using the label's font), adjust the label's width
* SizeFontToFit - given some text for the label (and using the label's width/height), adjust the label's fontsize so that the text fills the label
* MeasureExpectedSize - Returns Width/Height/FontSize (type SizeToFit_Metrics) for a label that hasn't yet been added to a parent view
* getFontSize & setFontSize - cross-platform subs to get/set the fontsize for a label
These routines will work under Android or IOS leading to a little more portability for developers supporting Apps running on both platforms. I've not tested on B4J.
IOS version is at https://www.b4x.com/android/forum/t...ingheight-measuremultilinestringheight.84070/
They can be used in place of or in conjunction with other routines like SizeToFit, MeasureStringHeight, MeasureStringWidth, MeasureMultilineStringheight etc.
Note that the attached is not a library - it's a code module with accompanying test/demo.
Requires: StringUtils library (MeasureMultilineTextHeight), Reflector library (GetActivityBA and GetField)
* SizeToFitWidth - given a width (and using the label's font), adjust the label's height
* SizeToFitHeight - given a height (and using the label's font), adjust the label's width
* SizeFontToFit - given some text for the label (and using the label's width/height), adjust the label's fontsize so that the text fills the label
* MeasureExpectedSize - Returns Width/Height/FontSize (type SizeToFit_Metrics) for a label that hasn't yet been added to a parent view
* getFontSize & setFontSize - cross-platform subs to get/set the fontsize for a label
These routines will work under Android or IOS leading to a little more portability for developers supporting Apps running on both platforms. I've not tested on B4J.
IOS version is at https://www.b4x.com/android/forum/t...ingheight-measuremultilinestringheight.84070/
They can be used in place of or in conjunction with other routines like SizeToFit, MeasureStringHeight, MeasureStringWidth, MeasureMultilineStringheight etc.
Note that the attached is not a library - it's a code module with accompanying test/demo.
Requires: StringUtils library (MeasureMultilineTextHeight), Reflector library (GetActivityBA and GetField)
Attachments
Last edited: