首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >贺卡翻转视图动画

贺卡翻转视图动画
EN

Stack Overflow用户
提问于 2013-05-18 14:17:08
回答 3查看 2.7K关注 0票数 1

我正在处理贺卡应用程序,我需要卡翻转视图类型的视图。我已经添加了相同的图片。我已经经历了多个类似翻转视图的库,我发现android-flipview更适合我的需求。我对这个库做了一些修改,使它像贺卡一样从左角翻转过来。我为它添加了代码和截图。

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

View_Dual_card.java文件,我做了这样的更改:

代码语言:javascript
复制
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);
        }
    }

我想要的:

我得到的是:

提前谢谢。

EN

回答 3

Stack Overflow用户

发布于 2013-05-18 14:57:55

最好使用页面卷曲,它简单且开源。https://code.google.com/p/android-page-curl/希望这能对你有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2013-05-18 14:30:33

此动画是一个简单的缩放和倾斜动画。

票数 0
EN

Stack Overflow用户

发布于 2013-08-03 06:14:57

图像似乎是倾斜的。请确保您的查看区域大于原始卡片。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16621331

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档