Android viewpager contains long text divided into pages
You can create multiple slices based on the dimension of the text measured with public float measureText (String text)
. Then you define the screen as mentioned in Get screen dimensions in pixels
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
And this way you can calculate the number of fragments you need.
For the splitting part, the fastest solution I can think of would be to loop with measureText (String text, int start, int end)
to determine where the text should be split. (There may be more elegant solutions out there)
source to share
Using the (Boring | Static | Dynamic) Layout classes to measure and wrap text, the Theses class takes width as a constructor parameter and calculates the overall height of your text, and also provides methods like getLineHeight (int line) to get the info string, so you can calculate the line offset according to this data. I am creating a class for this, see my answer here: fooobar.com/questions/2224506 / ...
source to share