umano / AndroidSlidingUpPanel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.
http://umano.me
Apache License 2.0
9.5k stars 2.27k forks source link

Sliding panel "jumps" when expanding and using SlidePanelListener #805

Open chrisjdavis42 opened 7 years ago

chrisjdavis42 commented 7 years ago

I am using SlidingUpPanel in my layout. The sliding panel contains a TextView that is set to wrap content. While the panel is collapsed the textview is set to maxLines = 2, and while the panel is expanded this should be changed to maxLines = 10 (this is because the text needs to be displayed with an ellipsis at the end if the panel is collapsed). I have the code to do this in the onPanelStateChanged method of a SlidePanelListener. However, when doing this, the panel "jumps" from its collapsed state to its expanded state without animating smoothly. Bizarrely, the other way around (going from expanded to collapsed) it works as it should and animates smoothly.

Can anyone explain to me why this is and if there is any way around it?

chrisjdavis42 commented 7 years ago

I think I've figured out what the problem is, but still not sure how to solve it. I think what is happening is that when I click on the panel while in its collapsed state, it does expand to the size of the textview's content. However, at this point, the textview is still set to maxLines = 2, so the expanded size is identical to the collapsed size (so essentially, the panel does not move at all). Once it has done this, only then does the panel state listener fire, the textview changes to maxLines = 10, and so the panel immediately resizes to wrap the content of its new size.

What I need is some way to tell the textview to change to maxLines = 10 before the panel starts expanding.