I have a simple multiple choice app for learning Chinese or Thai language. It loads words and definitions from an Excel file. Some definitions are long in length, some are short in length.
Is there a clever way to set the font width based on the width of the device?
Right now (if you look at the screenshots from my first post) I use 1 Label and 4 Buttons. Are you saying to add/embed these Views INSIDE a xCustomListView? How will it prevent the text cutoffs that I'm currently experiencing? Or do you suggesting I REPLACE these Views with a xCustomListView?
I am still trying to solve this "automatically adjust font size by size or length of text" issue for labels and buttons. I have created a small demo to show the problem.
Attached you find a modified version with an improved version of the first link.
The problem with Buttons is that they have a padding, which means that the text area is smaller than the view dimensions.
The StringUtils.MeasureMultilineTextHeight method doesn't take into account the padding.
Thanks Klaus
Most of the text I use adjusts correctly thanks to your code but there are some exceptions. To see some of these exceptions look at the attached screenshot. As you can see the Label1 and Button2 lines are problematic.
Set the limit to Private limit = 0.001 As Float
instaed of Private limit = 0.5 As Float
It seems that the text is at the limit betwwen one line and two lines:
On my device:
TextSize = 19.166 one line
TextSize = 19.167 two lines
Another suggestion, more efficient.
Set the limit to Private limit = 0.2 As Float
And replace: lbl.TextSize = lblDummy.TextSize
by lbl.TextSize = lblDummy.TextSize - 0.2