Diamond
Diamond

Reputation: 7483

How to set Textarea maximum number of rows

I have a Textarea that I use to display content only.

How do I set it it's maximum number of rows to 4, regardless of the string length.

Or is there a way to calculate amount of text that can fit in 4 rows on any device? I can use this to extract part of the string and set the text on the Textarea to this substring.

I have tried textarea.setRows(4);, but this seems to work only if I have to type in the text.

Upvotes: 2

Views: 1881

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

Try something like this:

textarea.setGrowLimit(4);
textarea.setRows(4);
textarea.setGrowByContent(false);

I'm not sure if grow limit is necessary once grow by content is disabled.

Upvotes: 2

Related Questions