Hi, I want to know your ideas about the most best way of doing the following.
I have label for writing some text on it, and I have a long string that I can check if it fits with MeasureStringWidth canvas method. e.g.:
When it doesn't fit, like in the previous example, I want to find out the character's index at the cutoff.
So, I thought of several ideas, but I want to know if there's a better way to do it:
1) The most inefficient way I can think of is to go backward 1 character at a time, until MeasureStringWidth < Label.Width
2) Do it by halves. Measure half of the string, compare widths, and repeat the process reducing the margin until finding the index.
3) ??
Any more ideas?
I have label for writing some text on it, and I have a long string that I can check if it fits with MeasureStringWidth canvas method. e.g.:
B4X:
Label.Width == 50
cnv.MeasureStringWidth(Text, Typeface, TextSize) == 258
When it doesn't fit, like in the previous example, I want to find out the character's index at the cutoff.
So, I thought of several ideas, but I want to know if there's a better way to do it:
1) The most inefficient way I can think of is to go backward 1 character at a time, until MeasureStringWidth < Label.Width
2) Do it by halves. Measure half of the string, compare widths, and repeat the process reducing the margin until finding the index.
3) ??
Any more ideas?