I’m using RichText class to put some text inside a ScrollView Instance.
I need to set the RichText width in order to split text in multiple lines.
To do that I did:
Unfortunately slarsky's fix did not work for me (I only get the single line height). Every attempt I’ve made to modify the contentSize of the RichText itself has failed. In order to get this to work I had to do several things:
Update the RichText object to calculate a text height value as the renderers are added.
Add a RichText child to a Layout object
a. Center position the RichText
b. Pass on the size of the Layout to the RichText
c. (Using the callback) Pass on the height of the RichText to the Layout
d. (Using the callback) Update the Y Position of the RichTextto 1.5 * height (why *1.5? because it works).
(code assumes this is a Layout containing a pointer to a RichText)
Now you will have a Layout that adjusts its height to the visible area of the RichText. Is this a little hacky…yes, but it works. If anyone can improve this code please let me know.