簡體   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