What i've tried to far:
Calling
measure()
tv.measure(0, 0); int height = tv.getMeasuredHeight();
Calling
measure()
with specified sizes/modesint widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(99999, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); tv.measure(widthMeasureSpec, heightMeasureSpec); int height = tv.getMeasuredHeight();
Calling
getTextBounds()
Rect bounds = new Rect(); tv.getPaint().getTextBounds(tv.getText().toString(), 0, tv.getText().length(), bounds); int height = bounds.height();
Calling
measure()
and then callinggetTextBounds()
- Calling
getLineCount() * getLineHeight()
None seem to work. They all return incorrect values (container view gets incorrect height - it's either too small or too large)
Ideas on how to calculate this simple thing??