How do I implement the type of page curl used in G

2019-02-10 01:52发布

问题:

I've been searching for a proper way to emulate the kind of page flipping/curling used in the iOS apps but in an Android app. The closest thing I have seen on Android is the Google Play Books app. Are they using some part of the SDK that I haven't seen? Is there any chance of getting my hands on a similar implementation?

Most of the examples I have seen are built using some sort of RenderView based on OpenGL. That would probably work, but I would have to make sure that the screen is not rendered in vain, since I don't want to use too much power. Also I'm a little afraid of using OpenGL when handling textures that are not pow2.

Best regards, Kalle

回答1:

You have to use OpenGl for making such effect in Android and have to use the below common sinusoidal graph equation :-

y=Asin(2π/λ*x)

Where,

A = Amplitude (i.e. the elevation of curl we want).

λ = Wavelength (i.e. the length of the curl we want).

x = The X axis variable which will change as you move the page.

You have to draw 3 pages on SurfaceView namely 'LeftPage' , 'CenterPage' and 'RightPage', 'CenterPage' is always visible and is responsible for 'right curl' animation while 'LeftPage' is responsible for 'left curl' animation and 'RightPage' just stay static. For detecting gestures use default GestureDetector class.

You can download the sample from here.