How do I know how long should be my String to not exceed one line (so I can substring it to myString.substing(0,maxOneLineLength-3)+"..."; and it fits one line perfectly ?
            Asked
            
        
        
            Active
            
        
            Viewed 93 times
        
    0
            
            
        
        Vlad Alexeev
        
- 2,072
 - 6
 - 29
 - 59
 
- 
                    That isn't how strings work. There is no 'end of line' until you reach a line break or your string runs out of memory. How long your string can be before the 'end of line' depends on what is containing the string. – dckuehn Dec 17 '13 at 21:32
 - 
                    So if I understand correctly, you have a fixed width (like a rectangle) in which you want to put some text, and you want the text to wrap(or resize to fit) when it gets to the edge of rectangle? – DoubleDouble Dec 17 '13 at 21:34
 - 
                    You may be tackling this problem from the 'wrong end' -there are layout properties for views that do this for you: http://stackoverflow.com/questions/1666736/android-textview-automatically-truncate-and-replace-last-3-char-of-string/1667339#1667339 – k2col Dec 17 '13 at 21:37
 - 
                    that really depends on the size of each letter in your font – njzk2 Dec 17 '13 at 21:58
 
1 Answers
1
            If you are using that on a TextView you should use android:ellipsize="end" instead. Also make sure android:singleLine="true" is set.
        rndstr
        
- 777
 - 8
 - 14