简体   繁体   English

如何在Android中实现Flip book的动画效果?

[英]How can I achieve Flip book kind of animation in android?

Basically I am developing Ebook Reading Android App where I need page curl Animation. 基本上,我正在开发需要页面卷曲动画的电子书阅读Android应用程序。 I have tried to achieve by using https://github.com/harism/android-pagecurl but having 2 issues 我试图通过使用https://github.com/harism/android-pagecurl来实现,但是有2个问题

1)Page-curl animation by harism not working properly when a page turns backwards For example : I go through pages until 4, then go back it loads page 4. If I go to another page back it should load page 3. Instead it loads page 5 . 1)当页面向后翻时,由束缚引起的页面卷曲动画无法正常工作例如:我浏览页面直到4,然后返回页面加载页面4。如果我返回到另一页面,它将加载页面3。第5页。 same issue were asked before but it gives some hints which I have already tried 之前曾问过同样的问题,但它给出了一些我已经尝试过的提示

Android Page Curl Animation by Harism shows inconsistency in the reverse index count in the getBitmap() method of CurlActiviy()? Harism开发的Android Page Curl Animation在CurlActiviy()的getBitmap()方法中的反向索引计数中显示不一致吗?

Page-curl animation by harism not working properly when a page turns backwards 当页面向后翻时,由束缚导致的页面卷曲动画无法正常工作

2) I am using TextView and creating Bitmap and i want scrolling,as Text View content is not fitting into screen so I m not clear will i able to achieve as 2)我正在使用TextView并创建Bitmap,并且我想滚动,因为Text View的内容不适合屏幕,所以我不清楚我能否实现
creating bitmap. 创建位图。

 private Bitmap loadBitmap(int width, int height, int index) {

        String text1, tittle;
        Bitmap txtBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        if (txtArr == null || txtArr.length == tempArrIndex + 1) {
            text1 = nitiinfoArrayList.get(pageindex).content;
            txtArr = text1.split(Constant.strpattern);
            pageCount = pageCount + txtArr.length;
            pageindex++;
            tempArrIndex = 0;
        } else if (txtArr.length > 1) {
            tempArrIndex++;
        }
        text1 = txtArr[tempArrIndex];
        int margin = 7;
        Rect r = new Rect(margin, margin, width - margin, height - margin);
        Canvas c = new Canvas(txtBitmap);
        Typeface ttf = Typeface.createFromAsset(context.getAssets(), "fonts/shruti.ttf");
        TextView tv = new TextView(getApplicationContext());
        tv.setText(text1);
        tv.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
        tv.setTextSize(18);
        tv.setTypeface(ttf);
        tv.setGravity(Gravity.CENTER);
        tv.layout(0, 0, getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
        Paint p = new Paint();
        p.setColor(getResources().getColor(R.color.chromelight));
        c.drawRect(r, p);
        tv.draw(c);
        c.drawBitmap(txtBitmap, 0, 0, null);

        return txtBitmap;
    }

Any suggestions or any other solution would be really appreciated. 任何建议或任何其他解决方案将不胜感激。 Thanks 谢谢

You should try deffinetly this library 您应该尝试该库

https://github.com/eschao/android-PageFlip https://github.com/eschao/android-PageFlip

It has really cool features and this is one of the best 它具有非常酷的功能,这是最好的功能之一

You can give a ratio of page width from 0 to 0.5f to set an area for reponsing click event to trigger a page flip. 您可以将页面宽度的比例设置为0到0.5f,以设置响应点击事件以触发页面翻转的区域。 The default value is 0.5f, which means the backfward flip will happen if you click the left half of screen and forward flip will start if you click the right half of screen in single page mode. 默认值为0.5f,这意味着在单页模式下单击屏幕的左半部分将发生向后翻转,而单击屏幕的右半部将开始向前翻转。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM