/ Apps

The library for creating book and card flip animations in ViewPager in Android

The library for creating book and card flip animations in ViewPager in Android

EasyFlipViewPager

The library for creating book and card flip animations in ViewPager in Android.

book_demo

poker_demo

gallery_demo

💻 Installation

Add EasyFlipViewPager in app's build.gradle file:

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

Or add EasyFlipViewPager as a new dependency inside your pom.xml

<dependency>
  <groupId>com.wajahatkarim3.easyflipviewpager</groupId>
  <artifactId>easyflipviewpager</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

❓ Usage

Just create an object of either BookFlipPageTransformer or CardFlipPageTransformer and assign it to your ViewPager object by calling ViewPager#setPageTransformer(true, myTransformerObject).

💳 Card Flip Example

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

// Create an object of page transformer
CardFlipPageTransformer cardFlipPageTransformer = new CardFlipPageTransformer();

// Enable / Disable scaling while flipping. If false, then card will only flip as in Poker card example. 
// Otherwise card will also scale like in Gallery demo. By default, its true.
cardFlipPageTransformer.setScalable(false);

// Set orientation. Either horizontal or vertical. By default, its vertical.
cardFlipPageTransformer.setFlipOrientation(CardFlipPageTransformer.VERTICAL);

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

📄 Book Flip Example

// 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);

GitHub