I have a long String that wraps to multiple lines, and that number of lines is different depending on the size of the Android device being used. Is there a way to know how many lines the text wraps to?
Asked
Active
Viewed 2,127 times
1 Answers
3
You can use one of the Layout classes:
Layout layout = new StaticLayout(text, /* other stuff--see docs */);
int nLines = layout.getLineCount();

Ted Hopp
- 232,168
- 48
- 399
- 521
-
Is there a way to do this in XML? – Kalina Sep 14 '12 at 21:31
-
1@TheBeatlemaniac - I don't think so. At the time the xml is compiled, there's no way for the system to know the device characteristics on which it will run. – Ted Hopp Sep 14 '12 at 21:33