android-layout - 贺卡翻页动画

标签 android-layout android-animation android android-custom-view

我正在开发贺卡应用程序,我需要卡片翻转 View 类型的 View 。我已经添加了相同的图像。 我经历过多个类似图书馆的翻转 View ,我发现了 android-flipview 更适合我的要求。 我对这个库进行了更改,使其像贺卡一样从左角翻转。 我正在为此添加代码和屏幕截图。

但是,它并不像我需要的那样工作。

查看_Dual_card.java文件,我做了这样的修改:

public synchronized void buildTexture(FlipRenderer renderer, GL10 gl) {
        if (screenshot != null) {
            if (texture != null)
                texture.destroy(gl);
            texture = Texture.createTexture(screenshot, renderer, gl);
            recycleScreenshot();

            topCard.setTexture(texture);
            bottomCard.setTexture(texture);

            final float viewHeight = texture.getContentHeight();
            final float viewWidth = texture.getContentWidth();
            final float textureHeight = texture.getHeight();
            final float textureWidth = texture.getWidth();

            if (orientationVertical) {
                topCard.setCardVertices(new float[] { 0f, viewHeight, 0f, // top left
                        0f, viewHeight / 2.0f, 0f, // bottom left
                        viewWidth, viewHeight / 2f, 0f, // bottom right
                        viewWidth, viewHeight, 0f // top right
                });

                topCard.setTextureCoordinates(new float[] { 0f, 0f, 0f,
                        viewHeight / 2f / textureHeight,
                        viewWidth / textureWidth,
                        viewHeight / 2f / textureHeight,
                        viewWidth / textureWidth, 0f });

                bottomCard.setCardVertices(new float[] { 0f, viewHeight / 2f,
                        0f, // top left
                        0f, 0f, 0f, // bottom left
                        viewWidth, 0f, 0f, // bottom right
                        viewWidth, viewHeight / 2f, 0f // top right
                        });

                bottomCard.setTextureCoordinates(new float[] { 0f,
                        viewHeight / 2f / textureHeight, 0f,
                        viewHeight / textureHeight, viewWidth / textureWidth,
                        viewHeight / textureHeight, viewWidth / textureWidth,
                        viewHeight / 2f / textureHeight });
            } else {
                topCard.setCardVertices(new float[] { 0f, viewHeight, 0f, // top left
                        0f, 0f, 0f, // bottom left
                        viewWidth /27f, 0f, 0f, // bottom right
                        viewWidth /27f, viewHeight, 0f // top right
                });

                topCard.setTextureCoordinates(new float[] { 0f, 0f, 0f,
                        viewHeight / textureHeight,
                        viewWidth / 27f / textureWidth,
                        viewHeight / textureHeight,
                        viewWidth / 27f / textureWidth, 0f });

                bottomCard.setCardVertices(new float[] {0f,
                        viewHeight, 0f, // top left
                        0f, 0f, 0f, // bottom left
                        viewWidth, 0f, 0f, // bottom right
                        viewWidth, viewHeight, 0f // top right
                        });

                bottomCard.setTextureCoordinates(new float[] {
                        viewWidth /27f / textureWidth, 0f,
                        viewWidth /27f / textureWidth,
                        viewHeight / textureHeight, viewWidth / textureWidth,
                        viewHeight / textureHeight, viewWidth / textureWidth,
                        0f });
            }

            checkError(gl);
        }
    }

我想要什么:

enter image description here enter image description here enter image description here

我得到的是:

enter image description here enter image description here enter image description here

提前致谢。

最佳答案

最好使用简单且开源的 page curl。 https://code.google.com/p/android-page-curl/希望这对你有帮助。

关于android-layout - 贺卡翻页动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16621331/

相关文章:

android - 如何在tablayout中设置2个tab等宽

android - 如何在 Activity 旋转时保存/恢复 MotionLayout 的状态

java - 并行动画 View

android - 我如何为我的 Gridview 实现触摸波纹?

java - 如何将下面的android方法转换为递归方法?

Android - 动态更新布局内容(以获得 "submenu"效果)

android - 如何清除NineOldAndroids设置的Animation Listener?

java - 使用套接字通过 Python 将图像文件从 Android 手机发送到 PC

android - CoordinatorLayout 中的 ViewPager 意外收缩

android - ViewFlipper 没有正确环绕图像