繁体   English   中英

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

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

基本上,我正在开发需要页面卷曲动画的电子书阅读Android应用程序。 我试图通过使用https://github.com/harism/android-pagecurl来实现,但是有2个问题

1)当页面向后翻时,由束缚引起的页面卷曲动画无法正常工作例如:我浏览页面直到4,然后返回页面加载页面4。如果我返回到另一页面,它将加载页面3。第5页。 之前曾问过同样的问题,但它给出了一些我已经尝试过的提示

Harism开发的Android Page Curl Animation在CurlActiviy()的getBitmap()方法中的反向索引计数中显示不一致吗?

当页面向后翻时,由束缚导致的页面卷曲动画无法正常工作

2)我正在使用TextView并创建Bitmap,并且我想滚动,因为Text View的内容不适合屏幕,所以我不清楚我能否实现
创建位图。

 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;
    }

任何建议或任何其他解决方案将不胜感激。 谢谢

您应该尝试该库

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

它具有非常酷的功能,这是最好的功能之一

您可以将页面宽度的比例设置为0到0.5f,以设置响应点击事件以触发页面翻转的区域。 默认值为0.5f,这意味着在单页模式下单击屏幕的左半部分将发生向后翻转,而单击屏幕的右半部将开始向前翻转。

暂无
暂无

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

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