How do you wrap a ui::RichText inside a ListView?

How do you wrap a ui::RichText inside a ListView?

Trying to add a ui::RichText to a ui::ListView*, but it doesn’t resize itself according to the listview. The following sizes it properly in the middle of a layer in a scene:

std::string xml = "<font color='#FF0000'>red</font> no red anymore <font color='#00FF00'>some <a href=''>link</a>other color</font>";
auto rich_txt = cocos2d::ui::RichText::create();
rich_txt->setNormalizedPosition({0.5, 0.5});

rich_txt->setContentSize({100, 0});

but if I add it to a ListView instead of another child in the scene, my_listview->addChild(rich_txt); the sizing gets all messed up.

For regular ui::Texts, this works after I call text->setTextAreaSize, which calls its label renderers’ setDimensions, but since RichText doesn’t have setDimensions, I’m in a tough spot here.

Has anyone had luck with properly wrapping RichTexts inside of a ListView?

The reason this doesn’t work with a Listview is that a RichText’s contentsize is hardcoded to use whatever you do with it it, when you disable ‘ignoreContentAdaptWithSize’, so the Listview thinks the content size is 0. Likewise there isn’t any bounds handling, like there is when you set text dimensions, so with a height of 0, the rest of the text is rendered in negative space.