Reputation: 11
How can I determine the number of visible characters that a TextView can display. For example if I change the orientation this number may change. If I change the resolution then also the number of visible characters changes.
Thanks in advance
Thank you for your answer.
Currently I am developing a small text based game to become acquainted with the Android API. For that reason I need to know exactly how much characters can be displayed in the visible area of a TextView widget. I saw an example of Paint but wanted to know if there are better solutions.
Upvotes: 1
Views: 1729
Reputation: 22920
You can use ellipsize property but there has been a bug that has been filed on the same
http://code.google.com/p/android/issues/detail?id=2254
On the bottom of this page you could find an alternate approach which can draw exactly the number of lines on a given space...
Upvotes: 0
Reputation: 1006614
Ideally, you design your GUI such that it does not matter. For example, you can use android:ellipsize
to deal with strings that are too long for the available space.
There are classes in the 2D drawing APIs (e.g., Paint
) that seem to be tied into this, but it does not look like much fun.
Upvotes: 1