You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My issue is that the button to expand the text only works on the first try. When I load the screen, I can expand the text correctly. However, when I try to collapse it, it looks like it's collapsing but then it expands again and then the button does not collapse or expand anything anymore. Running debug I can see that it is running collapse() method... It just is not correctly collapsing.
Expands fine here
Starts to collapse but gets about halfway before expanding again. Does not work after this
Can you provide me your layout file and a code snippet from your Fragment / Activity? I'll try to reproduce the issue on my side and help you out asap.
I have set max lines 4. On first load I have 4 lines. I click on the text, it expands. Than I click to collapse, it collapses to 4 and than expands back. Than if I click again nothing happens. Text stays expanded. expandText.setInterpolator(new OvershootInterpolator()); expandText.setMaxLines(4); expandText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(expandText.isExpanded()){ expandText.collapse(); } else{ expandText.expand(); } } });
How ever, I used a different approach at the end and I don't have the orig element, but this is the fragment layout where I used the ExpandableTextView. Now I is just a simple TextView, just renamned that one so you can see where it was originally. Same thing happen to me as mentioned above.
Hope it helps...
thanks for reporting this issue! If you want a quick fix for your problem, use android:maxLines="4" in your layout file instead of using expandText.setMaxLines(4); in your Activity / Fragment.
I'll add support for also using the setMaxLines() method.
I just changed any calls to setMaxLines() inside the ExpandableTextView class to call the super method, and then overrode both setMaxLines() and getMaxLines() to properly set and report ExpandableTextView's maxLines field.
Activity
[-]Won't collapse. Expands once but stops working after that.[/-][+]Expands once but won't collapse[/+]Cliffus commentedon Aug 13, 2016
Hi Michael
thanks for reporting this issue!
Can you provide me your layout file and a code snippet from your Fragment / Activity? I'll try to reproduce the issue on my side and help you out asap.
Thanks again!
Cliff
Cliffus commentedon Aug 21, 2016
Hi Michael
did you already find some time to check my previous questions to you?
Thanks!
Cliff
parohy commentedon Oct 14, 2016
I have set max lines 4. On first load I have 4 lines. I click on the text, it expands. Than I click to collapse, it collapses to 4 and than expands back. Than if I click again nothing happens. Text stays expanded.
expandText.setInterpolator(new OvershootInterpolator()); expandText.setMaxLines(4); expandText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(expandText.isExpanded()){ expandText.collapse(); } else{ expandText.expand(); } } });Layout is a bit stripped down..
`
`
How ever, I used a different approach at the end and I don't have the orig element, but this is the fragment layout where I used the ExpandableTextView. Now I is just a simple TextView, just renamned that one so you can see where it was originally. Same thing happen to me as mentioned above.
Hope it helps...
Cliffus commentedon Oct 15, 2016
Hi Tomas
thanks for reporting this issue! If you want a quick fix for your problem, use android:maxLines="4" in your layout file instead of using expandText.setMaxLines(4); in your Activity / Fragment.
I'll add support for also using the setMaxLines() method.
Good luck!
Adnan-addi commentedon Feb 1, 2017
how to use this textview in listview in listitem row with simpleAdapter?
pasniak commentedon Jul 29, 2018
Setting MaxLines in code is crucial for XML-free Kotlin's anko layouts...
zacharee commentedon Jun 25, 2020
I've made a forked version of this library that allows setting the max lines in code: https://github.com/zacharee/Android-ExpandableTextView.
Here's the relevant commit: zacharee@5fc91d3
I just changed any calls to
setMaxLines()inside the ExpandableTextView class to call the super method, and then overrode bothsetMaxLines()andgetMaxLines()to properly set and report ExpandableTextView'smaxLinesfield.