I’m trying to implement a function that when a TextView contains too many lines of text, it can be collapsed into 2 lines after a user taps a button. It is expected that when the user taps that button again, the TextView should then show the full text it contains.
In the collapseView() method, I use setEllipsize as below:
private void collapseView() {
m_vwText.setMaxLines(2);
m_vwText.setEllipsize(TruncateAt.END);
m_vwExpandButton.setText(EXPAND);
}
So I wonder what should I do in my expandView() method to show all lines contained in the TextView. Please help and thanks in advance.
An idea would be to take the original TextView value into a temporary variable and keep it there, and make use of it in the
customView()method.ex:, in
onCreate()Then in your
expandView()you just work withoriginalText