Android 页面卷曲动画

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3015586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:19:46  来源:igfitidea点击:

Android page Curl animation

androidcurlandroid-animationflip

提问by Meymann

  1. Is there a simple way to do the Curl page flipping animation? A Curl animation is animation of pages flipping, including the page above rolling and the shadows over the lower page.
  2. What is the recommended way to do a "gallery" that displays two pages at a time (just like a book)?

    Is it:

    1. Letting the adapter display a linear layout of two images at a time? (it won't let me show a page flipping over the other like a book)
    2. Using two pages, placing somehow one near the other, and then when it's time to animate -move the next two pages over? What is the better way that would enable displaying the left page flipping over the right page?
  1. 有没有一种简单的方法来做 Curl 页面翻转动画?卷曲动画是页面翻转的动画,包括滚动上方的页面和下方页面的阴影。
  2. 做一个一次显示两页的“画廊”的推荐方法是什么(就像一本书)?

    是吗:

    1. 让适配器一次显示两个图像的线性布局?(它不会让我像书一样显示一页翻过另一页)
    2. 使用两页,以某种方式将其中一页放在另一页附近,然后什么时候制作动画 - 将接下来的两页移过去?有什么更好的方法可以让左页翻过右页显示?

采纳答案by Moss

I'm implementing a 2D page curl in the native canvas. Check my answer in: Implement page curl on android?

我正在本机画布中实现 2D 页面卷曲。检查我的答案:在 android 上实现页面卷曲?

EDIT: The code project of my implementation: http://code.google.com/p/android-page-curl/EDIT2: Links updated

编辑:我实现的代码项目:http: //code.google.com/p/android-page-curl/EDIT2:链接更新

回答by Arslan Anwar

I am using this code. Its really really perfect for any one to understand and use. Thanks a lot to Harism

我正在使用此代码。它真的非常适合任何人理解和使用。非常感谢哈里斯

GitHub Link for Page Curl Animation in android With OpenGL

带有 OpenGL 的 android 页面卷曲动画的 GitHub 链接

回答by Lunin

I haven't worked on the android before, but it seems to me the best way to do a page flipping type of display would be to draw it in three layers. The first being the first page's text, the second being the "page" underneath, and the third being the next page. If you draw them from back to front, the only thing the user will see will be the text on the first page.

我以前没有在 android 上工作过,但在我看来,进行翻页类型显示的最佳方法是将其绘制成三层。第一个是第一页的文本,第二个是下面的“页面”,第三个是下一页。如果从后向前绘制它们,用户将看到的唯一内容将是第一页上的文本。

Now, Once you have that, you'll want to do some sort of curling/flipping animation based on whatever controls you are using. Simply choose whatever method works best for you for doing that animation, but while you are doing that, have the part of the page that isn't there anymore alpha'd out. This will allow you to see the text of the page underneath (Okay, I lied. You'll need a background behind that text too).

现在,一旦你有了它,你就会想要根据你使用的任何控件来做某种卷曲/翻转动画。只需选择最适合您制作该动画的方法,但是在您这样做的同时,将不再存在的页面部分进行 alpha 处理。这将允许您看到下方页面的文本(好吧,我撒谎了。您还需要该文本背后的背景)。

The problem at this point is you're still drawing the text twice over the same space, so you'll want to blend the first page's text with the animation under it. In this way, the text that is over the 0 alpha sections will be invisible. It won't bend with the animation, so that may still be an issue, but depending on the speed of the flip that might be fine still. When the animation is done, simply set the first page = the second, the animation reset to plain white, and the second page = the new second page.

此时的问题是您仍在同一空间内绘制两次文本,因此您需要将第一页的文本与其下方的动画混合。这样,超过 0 alpha 部分的文本将不可见。它不会随着动画而弯曲,所以这可能仍然是一个问题,但取决于翻转的速度,这可能仍然没问题。动画完成后,只需设置第一页 = 第二页,动画重置为纯白色,第二页 = 新的第二页。

The shadow effect can be done simply by partially alphaing out some black behind the page turn animation. Draw over second page (as the animation layer already is doing) and voila!

阴影效果可以简单地通过在翻页动画后面部分地去除一些黑色来实现。绘制第二页(因为动画层已经在做),瞧!

I believe your two page question could use a very similar method. Good luck

我相信您的两页问题可以使用非常相似的方法。祝你好运

回答by Anton

This is 3d animation project (based on OpenGL 2.0) - http://anettosoftware.co.uk/npc.php

这是 3d 动画项目(基于 OpenGL 2.0) - http://anettosoftware.co.uk/npc.php