Closed com314159 closed 9 years ago
set different text will also cause the same problem
solved by
add method: private int getTextViewRealHeight(TextView pTextView) { Layout layout = pTextView.getLayout(); int desired = layout.getLineTop(pTextView.getLineCount()); int padding = pTextView.getCompoundPaddingTop() + pTextView.getCompoundPaddingBottom(); return desired + padding; }
then in onMeasure change mMeasuredTextHeight = mTv.getMeasuredHeight() to mMeasuredTextHeight = getTextViewRealHeight(mTv);
Thanks, I will also look into this and get back to you.
Textview's getMeasuredHeight() was being affected by parent's heightMeasureSpec and not equal to the text's height. The fix will be merged in to the master branch soon and will be released as version 0.1.1 in the maven central.
The fix is in v0.1.1 and now published to the maven central. It should go live within a day.
Thank you for your help, "com314159 ".
Manabu
You can try add a button a your demo project, and on the onClickListener you set the dummy_text2 again. like
after the button clicked, (that is the same text is set again after view created and when textview is collapsed), the textview can't expand fully. I found the mMeasuredTextHeight is a wrong value.
may be I can solve this problem.
thank you for your code.