2

What's the best way to implement functionality in Android where I have a large amount of text (let's say a book), and I display one page at a time. However, instead of displaying it all at once, and having the user scroll through it, I would want to create it like iBooks where each page is separate, and the user "flips" through it [although, I don't need a fancy flip. A simple slide, like Kindle for iOS, would do].

So how should I go about this? Is creating a customview necessary, or is there some way to do it without that?

Ryan Gates
  • 4,501
  • 6
  • 50
  • 90
yydl
  • 24,284
  • 16
  • 65
  • 104

1 Answers1

3

Previously asked (I think): How to do page flip/turn/curl effect in android

Possibly answered: Implement page curl on android? with a project at http://code.google.com/p/android-page-curl/

If that doesn't do what you need, you will probably need a custom view, and you'll probably need to do some OpenGL work. The animation and page bending done (to simulate bending the corner of a page) is quite possible but would require some knowledge of the math, which appears to be described at the answer. Your mileage may vary.

EDIT: ah, see Android Left to Right slide animation

Community
  • 1
  • 1
Femi
  • 64,273
  • 8
  • 118
  • 148
  • I know I might not have been clear in the question: but I don't really care for all the fancy flipping stuff. Just a simple slide would also do. I'll update the question to reflect this... – yydl May 13 '11 at 03:02
  • Okay. That's good. Now how to tie into a book. Like it's probably a waste of resources to have a view for every page. So it would probably make the most sense to have 3/4 views, and keep changing the text as the user flips. So how to do the whole text thing? Or is there a better way? – yydl May 13 '11 at 03:09
  • A couple of views you slide in and out is probably the way to go: change the text on the off-screen one to the next page and then slide it onto the screen in the right direction. – Femi May 13 '11 at 03:12
  • One last thing: any way to calculate which text would end up on which page? – yydl May 13 '11 at 03:19
  • That would depend on font size, spacing, bold text and a bunch of other such items: I've never done much text reflow work but there are typically methods on the Font objects to let you do height and width calculations. – Femi May 13 '11 at 03:22
  • A pleasure: let me know how the final app turns out. – Femi May 13 '11 at 03:33