I would avoid using the textHeight property. Does it work better if you use the getElementPreferredHeight() method that LabelItemRenderer provides? See the renderer I created in this thread for an example.
getElementPreferredHeight() does fix the problem.
You're saying I should use getElementPreferredHeight() and getElementPreferredWidth() instead of other properties like textHeight or simply height in mobile item renderers?
I did read the MultilineLabelItemRenderer you created. It was a good read, taught me a lot. The reason I used textHeight in this particular case was that text was never going to be more than 2 lines, so I figured the added complexity isn't needed for such a simple case.
1 person found this helpful
Retrieving size information of an element in a renderer via getElementPreferredWidth()/getElementPreferredHeight() is the recommended approach.
getElementPreferredWidth() is a convenience method which works similar to how setElementSize() works in that it calls different APIs depending on what the element is typed as:
* A helper method to retrieve the preferred width of a child element.
* <p>This method is the recommended way to get a child element's preferred
* width. You can use this method instead of checking for and using
* various interfaces/classes such as ILayoutElement, IFlexDisplayObject,
* or StyleableTextField.</p>
* @param element The child element to retrieve the width for. The element could
* be an ILayoutElement, IFlexDisplayObject, StyleableTextField, or a generic
* @return The child element's preferred width.
* @see #getElementPreferredHeight
* @langversion 3.0
* @playerversion Flash 10.1
* @playerversion AIR 2.5
* @productversion Flex 4.5
protected function getElementPreferredWidth(element:Object):Number
if (element is ILayoutElement)
else if (element is IFlexDisplayObject)
Measuring a StyleableTextField can get really tricky and you really won't want to do it yourself if you don't need to. Using getElementPreferredWidth() will call StyleableTextField.getPreferredBoundsWidth() which in turn calls the mx_internal measuredTextSize() method. Check out the source code of those methods if you are interested in what measurement calculations are done behind the scenes.
OK, Steve. Thank you very much.