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
An android ViewPager extension allowing infinite scrolling

NO LONGER MAINTAINED LoopingViewPager An android ViewPager extension allowing infinite scrolling. You can use it with "standart" PagerAdapter (inflati

Leszek Mzyk 992 Nov 10, 2022
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

ogaclejapan 7k Jan 1, 2023
Pixplicity 915 Nov 8, 2022
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. Show some ❤️ ?? Sweet and short libra

Rakshak R.Hegde 180 Nov 18, 2022
UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.

UltraViewPager 中文文档 ProjectUltraViewPager is a ViewPager extension that encapsulates multiple features, mainly to provide a unified solution for multi

Alibaba 5k Dec 20, 2022
Persons cards list viewpager - Persons cards list viewpager using kotlin

persons_cards_list_viewpager Дизайн и условие взяты из https://github.com/appKOD

Mironov Ury 1 Mar 1, 2022
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.

WoWoViewPager WoWoViewPager combines ViewPager and Animations to provide a simple way to create applications' guide pages. When users are dragging WoW

黄伟平 2.7k Dec 30, 2022
A simple keyframe-based animation framework for UIKit. Perfect for scrolling app intros.

Jazz Hands is a simple keyframe-based animation framework for UIKit. Animations can be controlled via gestures, scroll views, KVO, or ReactiveCocoa. J

IFTTT 6.4k Dec 30, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 3, 2023
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 5, 2023
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Florent CHAMPIGNY 8.2k Dec 29, 2022
LiquidSwipe is a ViewPager library that can be used to make Awesome Onboarding designs.

LiquidSwipe LiquidSwipe is a ViewPager library that can be used to make Awesome Onboarding designs. Usage Set up the dependency Add the mavenCentral()

Farham Hosseini 4 Nov 5, 2021
Circular motion is a ViewPager library that can be used to make Awesome Onboarding designs.

CircularMotion Android Circular Motion Onboarding library Circular motion is a ViewPager library that can be used to make Awesome Onboarding designs.

Farham Hosseini 4 Nov 5, 2021
Augment Android's ViewPager with wrap-around functionality.

Infinite View Pager Augment Android's ViewPager with wrap-around functionality. Original StackOverflow question: http://stackoverflow.com/questions/75

Antony Tran 692 Dec 14, 2022
[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Andras Kindler 437 Dec 29, 2022
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

Manuel Peinado Gallego 253 Nov 16, 2022
Android ViewPager template with cool animation.

glazy-viewpager ViewPager template with cool animation. Preview Dependencies compile 'com.android.support:palette-v7:25.2.0' Usage Refer the implement

Kannan Anbarasan 251 Nov 29, 2022
Android Parallax-ViewPager

ParallaxViewPager Demo Usage <com.github.ybq.parallaxviewpager.ParallaxViewPager android:id="@+id/viewpager" android:layout_width="ma

ybq 588 Nov 29, 2022
Endless full-screen card ViewPager inspired by apple iBook for Android

FullScreenCardViewPager for Android Endless full-screen card ViewPager inspired by apple iBook for Android. ✅ We are open to any new feature request,

Iman Dolatkia 136 Dec 16, 2022