PageCurl animations on ViewPager transitions?

2020-08-26 07:03发布

问题:

Here's a demo of what a page curl animation looks like: http://www.youtube.com/watch?v=aVZHN_o45sg

There are a couple of page curl animation libraries:

  • https://github.com/harism/android_page_curl
  • https://github.com/MysticTreeGames/android-page-curl

They are meant to work with Bitmap Drawables and not necessarily ViewGroups. If was wondering if anyone has come up with a similar page curl transition for ViewPagers.

回答1:

Not a straight way..but, How about creating the bitmap of view group by getDrawingCache() method and pass the bitmap to library.



回答2:

This is a library that I just come across; it has a nice page curl transformation. It is not the exact same page curl that you want; but maybe some remedy to anyone

How it looks

Dependency

implementation 'com.wajahatkarim3.easyflipviewpager:easyflipviewpager:1.0.0'

Usage

// Get ViewPager and Set Adapter        
myViewPager = findViewById(R.id.myViewPager);
pagerAdapter = new MyPagerAdapter(this);
myViewPager.setAdapter(pagerAdapter);

// Create an object of page transformer
BookFlipPageTransformer bookFlipPageTransformer = new BookFlipPageTransformer();

// Enable / Disable scaling while flipping. If true, then next page will scale in (zoom in). By default, its true.
bookFlipPageTransformer.setEnableScale(true);

// The amount of scale the page will zoom. By default, its 5 percent.
bookFlipPageTransformer.setScaleAmountPercent(10f);

// Assign the page transformer to the ViewPager.
myViewPager.setPageTransformer(true, bookFlipPageTransformer);