views:

48

answers:

3

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

A: 

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.

CommonsWare
A: 

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.

Curlywurly
A: 

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...

Rahul