How do I determine how much text will fit in a TextView in Android?

You can create a Paint object with TextView2's text size and use breakText() to measure how many characters will fit in your TextView2's width (This is untested code - might need some slight modifications) String textToBeSplit = arbitraryText; // Text you want to split between TextViews float textView2Width = somehowGetItsWidth; // TextView2's width float myTextSize = textView2.getTextSize(); Paint paint = new Paint(); paint. SetTextSize(myTextSize); // Your text size int numChars = paint. BreakText(textToBeSplit, true, float textView2Width, null) numChars tells you how many characters in textToBeSplit will fit in TextView2's width, enabling you to split it between your views.

You can create a Paint object with TextView2's text size and use breakText() to measure how many characters will fit in your TextView2's width. (This is untested code - might need some slight modifications) String textToBeSplit = arbitraryText; // Text you want to split between TextViews float textView2Width = somehowGetItsWidth; // TextView2's width float myTextSize = textView2.getTextSize(); Paint paint = new Paint(); paint. SetTextSize(myTextSize); // Your text size int numChars = paint.

BreakText(textToBeSplit, true, float textView2Width, null); numChars tells you how many characters in textToBeSplit will fit in TextView2's width, enabling you to split it between your views.

Thank you for the rough example. I will work on this and let you know how it turns out. – groomsy Aug 4 '10 at 21:53.

Essentially, I need the contents of TextView 2 to wrap to the next line, but start where TextView 1 starts. I was thinking that if I knew how much text would fit into TextView 2 before it runs out of space on line one, I could take the rest of the text and put it in another TextView below the first two. So I need to measure how much text will fit into a TextView (which can be tricky because as far as I can tell, Android will try to break the text in a TextView at a good location so that it won't break a word in the middle if it can be avoided) or I need a new idea on how to lay this out.

Any help would be greatly appreciated.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions