简体   繁体   中英

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. I have tried to achieve by using https://github.com/harism/android-pagecurl but having 2 issues

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 . 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()?

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

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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