Great! :-/ (and thank you for preemptively softening the blow
)
Good questions, too (sadly!)
My first tack here would be to calculate it based on average text size, eg:
NumCharsPerLine = MyView.Width / (TextSize * some_constant)
NumLines = MyText.Length / NumCharsPerLine
LineHeight = TextSize * another_constant
MyView.Height = NumLines * LineHeight
and then you can fold the constants and make it one calculation:
MyView.Height = NumLines * LineHeight
MyView.Height = (MyText.Length / NumCharsPerLine) * (TextSize * another_constant)
MyView.Height = (MyText.Length / (MyView.Width / (TextSize * some_constant)) * (TextSize * another_constant)
MyView.Height = MyText.Length / MyView.Width * TextSize / some_constant * TextSize * another_constant
MyView.Height = MyText.Length * TextSize * TextSize * amalgamated_constant / MyView.Width
Hopefully I haven't mucked that up. It looks right, because:
AverageCharArea = TextSize * TextSize * amalgamated_constant
Area = NumChars * AverageCharArea
Height = Area / Width
Probably best to add a bit of extra height, to allow for partial lines and/or text with lots of wide characters. Could either just add a fixed amount, or something based on TextSize, and/or increase amalgamated constant.
The second tack was going to be Snapshot the ScrollView Panel to an image, then scan the image pixels to find the bottom of the text, but... I was getting B4A and B4J mixed up, and I don't know how to do the Snapshot in B4A. If you find out, let me know. Or there is some multiline text height function, but I don't know how it will handle justified layout. Give it a go - worst that'll happen is it doesn't work.
Yeah, good luck with this. Maybe CharSequences that decrease the font size of blank lines between paragraphs. Probably won't work, but you never know your luck in the big city. Or maybe there is a Unicode smaller-than-usual line break, same as there are smaller-than-usual spaces.
(... wanders off to do internet search ...)
Check this out:
http://www.unicode-symbol.com/u/008B.html
You can add it after each NewLine with:
MyView.SetText(MyText.Replace(Chr(10), Chr(10) & Chr(0x8B), False)
or maybe even replace the NewLines for the case where JustifyTextView is already adding blank space between paragraphs:
MyView.SetText(MyText.Replace(Chr(10), Chr(0x8B), True) 'I might have True and False around the wrong way (am away from test bench)
but no guarantees, I'm just tossing ideas into the mix that documention indicates should/could work.