Git Product home page Git Product logo

android-easytransformpager's Introduction

Android-EasyTransformPager

Making amazing animation with ViewPager is not ever a pain!

This is a library which make easier the use of page transformer in Android ViewPager. Instead of creating a custom pager transform and make all work manually, just use the EasyTransformPager with its own fragment pager adapter and its own fragment. It allows you, by overriding just one method, to make any view independent animation.



![Let's see below](/docs/easytransformpager.gif?raw=true "Optional Title")

Usage

For a simple implementation, take a look at the "sample" directory.

  1. Include the library as a local library porject or add the dependence in your build.gradle.

     dependencies {
         compile 'com.github.rajyvan:EasyTransformPager:1.1'
     }
    
  2. Include the EasyTransformPager in your layout. It should replace the android support ViewPager.

          <mg.yra.lib.AnimatedViewPager
           android:layout_height="match_parent"
           android:layout_width="match_parent" />
    
  3. Extend from AnimatedPagerAdapter. It's a FragmentStatePagerAdapter. You should return a AnimatedFragment type.

     public class MyPagerAdapter extends AnimatedPagerAdapter {
           public MyPagerAdapter(FragmentManager fm) {
                  super(fm);
           }
     
           @Override
           public AnimatedFragment getItem(int position) {
                  // TODO
                  return null;
           }
     
           @Override
           public int getCount() {
                  return 10;
           }
     }
    
  4. For every AnimatedFragment, override the method transformPage(View view, float offset).
    View is the main view container that you inflate inside your fragment.
    Offset represents the percentage of visibility of your fragment page according to screen width. Offset equals 0 for invisible page, 1 for full visible page.

     @Override
     public void transformPage(View view, float offset) {
            // TODO
            // Example
           view.findViewById(R.id.textView).setAlpha(1-offset);
           view.setTranslationY((float) ((1 - offset) * 0.32 * view.getWidth()) * offset);
           view.setRotation(360 * offset);
           view.setAlpha(1-offset);
     }
    

Changelog

Current version : 1.1

Developed by

Yvan RAJAONARIVONY [email protected]

android-easytransformpager's People

Contributors

rajyvan avatar

Watchers

James Cloos avatar Al Amin Shadhin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.