how to change pages in Viewpager with overlap(Parallax) of ImageViews like in this app ?
Some day I saw a library, but don't remember where...

- 11,794
- 12
- 98
- 138
-
1what do u mean by "material Image view"? There're two different layouts, both added to a ViewPager via Adapter. Please clarify your question. – Budius Jan 12 '16 at 10:54
-
@Budius, not find fault with words, I know that you understood my question. Do you know how to do that ? – NickUnuchek Jan 12 '16 at 11:42
-
@NickUnuchek I literally have no idea what u mean, but sounds like it's something I could help, that's why I (and @piotrek1543) asked you to clarify the question. – Budius Jan 12 '16 at 11:43
-
@Budius how to change pages in Viewpager with overlap of ImageViews? – NickUnuchek Jan 12 '16 at 11:45
1 Answers
the actual question from the OP is:
how to change pages in Viewpager with overlap of ImageViews?
That have nothing to do with material design, it's a technique that exist for quite a few years in Android. This technique in general is called "parallax effect": https://en.wikipedia.org/wiki/Parallax_scrolling
To achieve it in Android is quite simple:
just call pager.setPageTransformer(false, transformer);
with an object that implements https://developer.android.com/reference/android/support/v4/view/ViewPager.PageTransformer.html
and then on the transformer callback you can simple call:
public void transformPage (View page, float position) {
page.findViewById(R.id.imageView).setTranslationX( .. do here some fancy math to move the image ...)
}
Other examples can be found on the following links.
Android Parallax Effect and View Pager
Parallax Effect in Android's ViewPager
Personally I don't like those link implementation much because they use 3rd party libraries to implement something that can be done literally with a couple of lines of code.