Pagination in ANDROID #18

ritika-mittal opened this Issue May 1, 2012 · 4 comments

3 participants



I have shown the spines in pages but what if the spine has a long data? How can i show them in pages?? I know there has been the same issue logged but i didnt get any help :( .

Ritika Mittal


The short answer is: by processing the text and cutting it into page-sized chunks.

Longer answer: this means you cannot directly display the text in a webview, but you have to process it first.

@ritika-mittal ritika-mittal reopened this May 9, 2012

By processing the text do you mean that i need to parse the whole xhtml spine and setting spans for each tag??


From your comments on another issue I understand you're using HtmlSpanner now.

This means you should already have a Spanned text, so now all you have to do is to take the right sub-string to leave you with exactly one page of text. My solution was to use a StaticLayout to measure how much text fits on the screen, and then put that sub-string in the TextView.

Take a look at this code to see what I mean, but be careful: it's GPL licenced:



I am also using staticLayout. But, My layout.getLineStart(topLine); and layout.getLineEnd(bottomLine) not working properly. It's giving topLine number+1 and bottomLine number +1 value :( I Have tried/searched lot but no luck. Could you please help me on this regard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment