Reputation: 8556
I have a TextView
in which I have to display a large amount of text, but I don't want to show all the text, only three lines and add a button Click to read more
, and after clicking on it all the text must expand. How I can implement this functionality and change the number of lines of the text dynamically?
Upvotes: 2
Views: 2668
Reputation: 33495
Most likely you are looking for setLines()
method. All what you need is to register OnClickListener for Button and perform appropriate action:
t = (TextView) findViewById(R.id.textViewId);
t.setLines(3);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
t.setLines(8);
}
});
Upvotes: 2