Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

Overview

CircleCI License Maven Central

ViewPagerTransforms

Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the JazzyViewPager library and owes credit of the animation concepts directly to its source. The purpose of this rewrite is to provide an easier to use and extend implementation of ViewPager animations.

Demo

Getting Started (Gradle / Android Studio)

Add gradle dependency to your application.

implementation 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:2.0.24'

After configuration, instantiate the transformer animation you wish to use and set it as the page transformer.

// Reference (or instantiate) a ViewPager instance and apply a transformer
pager = (ViewPager) findViewById(R.id.container);
pager.setAdapter(mAdapter);
pager.setPageTransformer(true, new RotateUpTransformer());

Creating Custom Transforms

All ViewPagerTransform implementations extend ABaseTransformer providing useful hooks improving readability of animations and basic functionality important when switching between animations. ABaseTransformer provides three lifecycle hooks and two flags for default handling of hiding offscreen fragments and mimicking the default paging functionality of the ViewPager.

Building

This project is built with Gradle using the Gradle Wrapper script.

./gradlew build

Creating Local Versions

You can modify this project and create local packages with via the maven publish plugin used in the build scripts.

./gradlew publishToMavenLocal
Comments
  • DepthPageTransformer not working properly on Android 4.1

    DepthPageTransformer not working properly on Android 4.1

    I had problem with RecyclerView in ViewPager with DepthPageTransformer, it wouldn't scroll, only on last page. Not sure what is the problem, just wanted you to know, I'll just use another one.

    bug help wanted 
    opened by akrezic1 10
  • Cube Out Not working on Android 7.0

    Cube Out Not working on Android 7.0

    I have implemented the cube out transformer it works fine in all my devices however, on android 7.0 its not working properly. The setRotationY seems to have an issue.

    How can I solve this?

    opened by salvonos 4
  • Buttons in each of ViewPager pages no longer clickable after applying DepthPageTransform

    Buttons in each of ViewPager pages no longer clickable after applying DepthPageTransform

    Hey,nice job ViewPagerTransforms.Am using the DepthPageTransform on my ViewPager and getting issues.On each of my ViewPager pages there is a button,this button is no clickable after applying the above Transform...Removing the Transform fixes the issue...What do I do? Thanks

    opened by wanclem 4
  • Slide vertically

    Slide vertically

    In this demo sliding is horizontal, Is there any way to slide view up n down instead of left right ? Animation also be vertical eg. Vertical stack transformation when I slide up n down..plz help..

    opened by nikhilB93 4
  • repair ZoomOut click event bug

    repair ZoomOut click event bug

    int zoom out transformer when the previous slider zoom out, it still on the above layer of current slide ( just transparent ). When you want to catch the click event, the previous slider will get it instead of current.

    So, we have to do another thing to make it disappear. move it to the left.

    (I 'm not sure if i describe it clear. you can try to add click event to each slider , and to see it ) :-D

    opened by daimajia 4
  • button and swipe controls don't work after more than 4 pages added

    button and swipe controls don't work after more than 4 pages added

    I am using FragmentStatePagerAdapter, ViewPager, v4.Fragments and the CubeOutTransformer. When I use the following code: CubeOutTransformer ct = new CubeOutTransformer(); mViewPager.setPageTransformer(true,ct);

    and add more than 4 pages the Button and gesture controls on the 5 page don't work. When I comment out the above code, the 5th page's controls work fine. Am I missing something... possible max setting??? Thanks

    opened by mooseandpebs 3
  • resolve problem: new page can't handle click event!

    resolve problem: new page can't handle click event!

    Using FlipHorizontalTransformer with viewPager.

    The next fragment can't handle touch event after switch page, because the last fragment is above the next fragment!

    opened by rdshoep 3
  • Cannot set 'scaleX' to Float.NaN

    Cannot set 'scaleX' to Float.NaN

    Fatal Exception: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN at android.view.View.sanitizeFloatPropertyValue(View.java:16995) at android.view.View.sanitizeFloatPropertyValue(View.java:16969) at android.view.View.setScaleX(View.java:16358) at com.ToxicBakery.viewpager.transforms.ScaleInOutTransformer.onTransform(ScaleInOutTransformer.kt:11) at com.ToxicBakery.viewpager.transforms.ABaseTransformer.transformPage(ABaseTransformer.kt:56) at androidx.viewpager.widget.ViewPager.onPageScrolled(ViewPager.java:1915) at androidx.viewpager.widget.ViewPager.pageScrolled(ViewPager.java:1842) at androidx.viewpager.widget.ViewPager.scrollToItem(ViewPager.java:694) at androidx.viewpager.widget.ViewPager.onLayout(ViewPager.java:1786) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1193) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:880) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:899) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1231) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:1067) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3427) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2894) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1942) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8595) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:988) at android.view.Choreographer.doCallbacks(Choreographer.java:765) at android.view.Choreographer.doFrame(Choreographer.java:700) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7156) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

    opened by FunkyMuse 2
  • Fixed issue on Android 4 where position was outside of the -1f..1f boundaries

    Fixed issue on Android 4 where position was outside of the -1f..1f boundaries

    This issue is quite specific to our project. We use a continuous scrolling ViewPager with an infinite amount of pages.

    Somehow the position retrieved in the 'transformPage' method exceed the boundaries on Android 4. This causes messed up animations where the wrong view animated which causes you to get stuck.

    This fix makes sure that the position is always within it's boundaries and does not change any behaviour for working implementations.

    opened by Sammekl 2
  • clicklistner on pager

    clicklistner on pager

    how to get the data of fragment from view pager. I tried to set onClicklistener in fragment onCreateview like this

    textViewPosition.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(),textViewPosition.getTag().toString(),Toast.LENGTH_LONG).show();
        }
    }); 
    

    but not working,please help.... Thanks in advance

    opened by GitEliteNovice 2
  • support v4 library

    support v4 library

    I've wanted to import your lib to my project and because it is v13 support I couldn't do it via maven. It is a shame because there is nothing preventing this from been v4 support, I've already made the changes took less than 10 minutes. you should consider doing the same upon releasing the next version.

    enhancement 
    opened by TacB0sS 2
  • Not working with viewpager2

    Not working with viewpager2

    I have used this with the viewpager2 but application is crashing after applying this transformation. error -> ( com.ToxicBakery.viewpager.transforms.CubeOutTransformer cannot be cast to androidx.viewpager2.widget.ViewPager2$PageTransformer)

    opened by saurav12bisht 0
  • fragment size reduced after transition

    fragment size reduced after transition

    Height and Width of my fragment decreased after Page Transformation. I'm using BackgroundToForegroundTransformer. After the transformation, i want to set my fragment size to original size. I don't want to decrease the height and width of my fragment. How can i do it ?

    opened by kpradeepkumarreddy 0
  • Bug when want to change current position without smooth

    Bug when want to change current position without smooth

    How to test bug: add next code in onCreate, run app, choose some transformation and wait for 6 seconds, it will change something but slider won't appear or animation would be frozen (paused at its start)

            // test bug
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mPager.setCurrentItem(4, false);
                }
            }, 6000);
    
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            int selectedPage = 0;
            if (savedInstanceState != null) {
                mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS);
                selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE);
            }
    
            final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<>(
                    getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1, TRANSFORM_CLASSES);
    
            setContentView(R.layout.activity_main);
    
            mAdapter = new PageAdapter(getFragmentManager());
    
            mPager = (ViewPager) findViewById(R.id.container);
            mPager.setAdapter(mAdapter);
            mPager.setCurrentItem(selectedPage);
    
            // test bug
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mPager.setCurrentItem(4, false);
                }
            }, 6000);
    
            final ActionBar actionBar = getActionBar();
            if (actionBar != null) {
                actionBar.setListNavigationCallbacks(actionBarAdapter, this);
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    
                //noinspection ResourceType
                actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);
    
                actionBar.setSelectedNavigationItem(mSelectedItem);
            }
    
        }
    

    for example with ZoomOutSliderTransformer slider won't be fully 100% taking all space of layout (you can see white paddings or margin at right and bottom)

    screenshot_2017-10-01-18-40-51-795_com toxicbakery viewpager transforms

    opened by anonym24 2
  • onClick listers wrong reference, not passing focus

    onClick listers wrong reference, not passing focus

    Hi, I am using your library, trying to implement FlipHorizontalTransformer

    Inside my view pagers I have fragments with buttons, and their onClickLIsteners...but every time I use your library, these listeners start to overlap:

    I have 2 pages: On page on i have Button1 and on page 2 i have Button2 (on same sort of relative location)

    But when I am on page2 and click to Button2 -> Button1 onClick lister fires up!!!

    Its like this page never left screen...its still on top (but hidden)...can you explain how to fix this ?!

    opened by radvansky-tomas 0
  • FlipHorizontal and FlipVertical changes incorrect IMO

    FlipHorizontal and FlipVertical changes incorrect IMO

    Don't have time to do a proper change, test, and pull request so I'm just going to write this issue. If no one fixes, I'll come back to make the change and pull request after my app release.

    Problem: those modifications have the side effect that if I change transformations after a vertical or horizontal flip, when I swipe the other direction, the off screen view, which is now on screen, remains hidden.

    I believe the framework already (sort of) supported the necessary change to remedy this. For anyone that runs into the problem, make the following change to ABaseTransformer: if (hideOffscreenPages() && (position <= -1f || position >= 1f)) { page.setVisibility(View.INVISIBLE); page.setAlpha(0f); // page.setEnabled(false); } else { // page.setEnabled(true); page.setAlpha(1f); page.setVisibility(View.VISIBLE); } And then you can remove the onPostTransform from FlipHorizontal and FlipVertical.

    In doing other work I did a limited amount of research on alpha vs visibility. I found a post from Romain Guy saying to use visibility and not alpha to hide/show as it's more efficient. The original defects were due to the framework using alpha to hide. The partial fixes switched to using visibility to prevent interaction with "off screen" pages, as it should be IMO. Problem is the side effect I found. Moving this into the framework itself fixes both these transformations and future transformations.

    I left the alpha change in as it's necessary to clean up after some transformations. I don't think the setEnabled is necessary and it's commented out in my copy.

    To the original developer that fixed the Flip transformation, thank you! I'd been having a problem being unable to scroll after a transformation and not taking the time to debug. Your fix helped very much.

    opened by pandasys 1
Releases(2.0)
Owner
Ian Thomas
I heard Kotlin is good
Ian Thomas
☯️Sophisticated and cool intro with Material Motion Animations(No more viewpager transformer or Memory leak)

Material Intro Sophisticated and cool intro with Material Motion Animations. Who's using Material Intro? ?? Check out who's using Material Intro Inclu

Ranbir Singh 34 Sep 8, 2022
Android library for material scrolling techniques.

material-scrolling Android library for material scrolling techniques. Features Easily implement material scrolling techniques with RecyclerView. Custo

Satoru Fujiwara 601 Nov 29, 2022
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
An Android library which provides simple Item animations to RecyclerView items

RecyclerViewItemAnimators Library Travis master: This repo provides: Appearance animations Simple animators for the item views Quick start You can now

Gabriele Mariotti 3.1k Dec 16, 2022
Android library to create complex multi-state animations.

MultiStateAnimation Android library to create complex multi-state animations. Overview A class that allows for complex multi-state animations using An

Keepsafe 405 Nov 11, 2022
Lightweight Android library for cool activity transition animations

Bungee min SDK 16 (Android Jellybean 4.1) written in Java A lightweight, easy-to-use Android library that provides awesome activity transition animati

Dean Spencer 172 Nov 18, 2022
A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix.

SuperForwardView About A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix. GIF Design Credi

Ertugrul 77 Dec 9, 2022
FragmentTransactionExtended is a library which provide us a set of custom animations between fragments.

FragmentTransactionExtended FragmentTransactionExtended is a library which provide us a set of custom animations between fragments. FragmentTransactio

Antonio Corrales 1.1k Dec 29, 2022
💠Metaphor is the library to easily add Material Motion animations

Metaphor Metaphor is the library to easily add Material Motion animations. Who's using Metaphor? ?? Check out who's using Metaphor Include in your pro

Ranbir Singh 132 Dec 25, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Orbitary ?? Jetpack Compose animation library that allows you to implement animations such as shared element transition. Download Gradle Add the depen

Jaewoong Eum 503 Dec 30, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

?? Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Jaewoong Eum 504 Jan 2, 2023
Actions for android animations. Inspired by libgdx scene2d actions.

Android Animations Actions Actions for android animations. Inspired by libgdx scene2d actions. The main goal of this project is making creating of com

dtx12 137 Nov 29, 2022
Render After Effects animations natively on Android and iOS, Web, and React Native

Lottie for Android, iOS, React Native, Web, and Windows Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations expo

Airbnb 33.5k Jan 4, 2023
Android Transition animations explanation with examples.

UNMAINTAINED No maintainance is intended. The content is still valid as a reference but it won't contain the latest new stuff Android Transition Frame

Luis G. Valle 13.6k Dec 28, 2022
The lib can make the ActivityOptions animations use in Android api3.1+

ActivityOptionsICS 本项目停止维护 =========== f you are thinking on customizing the animation of Activity transition then probably you would look for Activit

Kale 591 Nov 18, 2022
Circle based animations for Android (min. API 11)

CircularTools Circle based animations for Android (min. API 11) Currently implemented: Circular reveal Circular transform Radial reaction Reveal:YouTu

AutSoft 209 Jul 20, 2022
Repository for android animations Rx wrapper

RxAnimations RxAnimations is a library with the main goal to make android animations more solid and cohesive. Download compile 'oxim.digital:rxanim:

Mihael Francekovic 479 Dec 30, 2022
AXrLottie (Android) Renders animations and vectors exported in the bodymovin JSON format. (Using rLottie)

AXrLottie (Android) Renders animations and vectors exported in the bodymovin JSON format. (Using rLottie)

AmirHosseinAghajari 128 Nov 26, 2022
Add Animatable Material Components in Android Jetpack Compose. Create jetpack compose animations painless.

AnimatableCompose Add Animatable Material Components in Android Jetpack Compose. Create jetpack compose animation painless. What you can create from M

Emir Demirli 12 Jan 2, 2023