I want to create a text reader, which will cut the text and put it in the TextView (represents my pages) and one after the other. These are contained in a ViewFlipper (represents my entire text), which allows me to turn the pages.
By cons I can not cut my text intelligently. For now I limit each TextView to a number of characters, but it is very unstable. Indeed some letters take up more space than others .. We can not use this method.
How can we know what quantity of text will enter into a TextView?
I tried to find the maximum size of my View manually . I invoked in:
float test = view.getPaint().measureText(myString);
It works well. When I put 480 letters (0 and 1), I get to 14,400 and my text is entirely within the screen. With:
1 -> 12.0 0 -> 12.0 é -> 11.0 \n -> 13.0 \r -> 7.0
total to fill the page -> 14400
The problem is that the line breaks and carriage return are causing problems.
If I have only letters or numbers in my string, so good: if we respect the maximum size of 14,400, everything is displayed on the screen. No Problem!
By cons, if a line breaks or a carriage return, it does not work. Even if we we respect the limit of 14400, the text above and is not fully displayed.
This is because the "MeasureText" method;" only returns 13 for a line break. But it's weird, a line break should account for at least 480 to make it consistent.
How do publishers eBook (Moon Reader, + Aldiko) for the text to be formatted so good? Each page has the same height, the text ends in the same place ..