Skip to content

AndroidDeveloperLB/ParallaxViewPagers

Repository files navigation

ParallaxViewPagers

A POC to show how to have multiple ViewPagers work in Parallax effect with each other

Code is based on this StackOverflow post: http://stackoverflow.com/q/31138652/878126

Demo

Here's how it looks like:

enter image description here

How to import

Currently, because there is an issue (read below), I didn't put an official release, but you can still use Gradle in case you don't care or can't reproduce the issue in your app (link here) :

repositories {
	    maven {
	        url "https://jitpack.io"
	    }
	}

dependencies {
	        compile 'com.github.AndroidDeveloperLB:ParallaxViewPagers:19516eb03a'
	}

How to use

Just prepare the viewpagers, and for each "viewPager" that you need to allow to affect "viewPager2" , use:

viewPager.addOnPageChangeListener(new ParallaxOnPageChangeListener(viewPager,viewPager2,masterRef));

where "masterRef" is a shared AtomicReference variable that's used to decide which of them is the current "master" to affect the others.

Example of 2 ViewPagers, each can affect the other:

AtomicReference<ViewPager> masterRef=new AtomicReference<>();
viewPager.addOnPageChangeListener(new ParallaxOnPageChangeListener(viewPager,viewPager2,masterRef));
viewPager2.addOnPageChangeListener(new ParallaxOnPageChangeListener(viewPager2,viewPager,masterRef));

Known issues

Sometimes, the other ViewPager might have a "flashing" effect. A workaround for this, is to pass the touch events from the container of the various viewpagers, to the master viewpager.

About

A POC to show how to have multiple ViewPagers work in Parallax effect with each other

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy