I have a TextView which firstly shows a small portion of a long text.
The user can press a \"see more\" button to expand the TextView and s
You can use the new TransitionManager for the animation and calling the maxLines attribute to set the amount
fun toggleReadMoreTextView(linesWhenCollapsed: Float) {
if (viewDataBinding.textView.maxLines != Integer.MAX_VALUE) {
// exapand
viewDataBinding.textView.maxLines = Integer.MAX_VALUE
} else {
// collapse
viewDataBinding.textView.maxLines = linesWhenCollapsed
}
// start animation
TransitionManager.beginDelayedTransition(viewDataBinding.constraintLayout)
}