7

Can any one tell me how to make page turn effect in Android?
Can any one please provide me some code snippet.

Alpine
  • 3,838
  • 1
  • 25
  • 18
Kumar
  • 5,469
  • 20
  • 64
  • 87
  • Do you mean so it actually looks like a page turning or just Views sliding left and right when you swipe your finger across the display? – Intrications Oct 06 '09 at 08:37
  • i m expecting that,views should slide left and right when swipe fingers across the display. – Kumar Oct 06 '09 at 08:52

1 Answers1

6

Take a look at this.

It's a Calculator application, which changes between normal/scientific mode on swipe gesture:

onFling(MotionEvent, MotionEvent, float, float)

It uses TranslateAnimation to accomplish the effect, but dragging between the views and tracking your finger, like in the iPhone is not implemented. Try using

onScroll(MotionEvent, MotionEvent, float, float)

for that.

As for Flexbook-like component, it shouldn't be hard to implement, if you use the masking approach.

Android M3 (pre-1.0 version) even had PageTurner widget, but it got deprecated, since it wasn't generic-enough, like the other widgets. You can try and dig up the old Android sources to find the implementation of PageTurner and modify it for Cupcake/Donut.

Dimitar Dimitrov
  • 16,032
  • 5
  • 53
  • 55
  • Yup, unfortunately Google Code Search was shut down. Here's another location of the component: http://gitorious.org/0xdroid/packages_apps_calculator/blobs/42d696406d2e83c3cbb1bd424ed53f6676121e8f/src/com/android/calculator2/PanelSwitcher.java – Dimitar Dimitrov Mar 09 '12 at 13:03