Manabu-GT / ExpandableTextView

Android's TextView that can expand/collapse like the Google Play's app description
Apache License 2.0
4.08k stars 791 forks source link

In the recyclerview, the expansion does not display the entire content correctly. #65

Open qinxianyuzou opened 5 years ago

qinxianyuzou commented 5 years ago

According to debug, I think that the number of rows that get the textview is incorrect. The number of rows obtained before the super.onMeasure() method is correct (may be 0), but the number of rows obtained after this is less. Up ------------------------------Above from Google Translate, the following is the original---------------------- 根据debug,我认为是获取textview的行数不正确导致的,在super.onMeasure()方法之前获取到的行数是正确的(也可能是0),但是在这之后获取到的行数变少了

qinxianyuzou commented 5 years ago

I see a problem, because mRelayout this switch affect the execution of onMeasure, this switch will only limit the re-measurement at the time the text changes, and in recyclerView in, setText time may not accurately measure the width and height, needs The measurement is accurate after the complete itemView is drawn, so just let the onMeasure perform the measurement smoothly after the view is drawn to solve the problem. My current solution is to remove the mRelayout condition. I don't know what it will do now,maybe it affects performance? ------------------------------Above from Google Translate, the following is the original---------------------- 我发现了问题所在,是因为mRelayout这个开关影响了onMeasure的执行,这个开关限制了只有在文本变化的时候才会重新测量,而在recyclerView中,setText的时候可能并不能测量准确的宽高,需要在完整的itemView绘制之后测量才准确,因此只要让onMeasure在view绘制之后也能顺利往下执行测量就能解决问题。我目前的解决办法是把mRelayout这个条件去掉,目前不知道这样会有什么影响,也许是影响性能?

eniz1806 commented 5 years ago

Yes, you are right. I have same problem. I see just half of my text when I do expand. Any solution out there for this? Thank you.

qinxianyuzou commented 5 years ago

Yes, you are right. I have same problem. I see just half of my text when I do expand. Any solution out there for this? Thank you.

Please see my reply above. if (!mRelayout || getVisibility() == View.GONE) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; } to if (getVisibility() == View.GONE) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; }

taichushouwang commented 3 years ago

Yes, you are right. I have same problem. I see just half of my text when I do expand. Any solution out there for this? Thank you.

Please see my reply above. if (!mRelayout || getVisibility() == View.GONE) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; } to if (getVisibility() == View.GONE) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; }

In my case, remove mRelayout may cause shrink when click the textview first, so I also change the Animation reference #55