Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems that the effect you're looking for is one of the samples for <a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.html" rel="noreferrer">ViewPager</a> in the android developer's website.</p> <p>Check out <a href="http://developer.android.com/training/animation/screen-slide.html#depth-page" rel="noreferrer">http://developer.android.com/training/animation/screen-slide.html#depth-page</a> , in the <em>Depth page transformer</em> section. It has a video and source code.</p> <p>Using a <a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.PageTransformer.html" rel="noreferrer">ViewPager.PageTransformer</a> you can decide how the pages behave when switching from one to the next.</p> <p>The only difference between the sample and the video you linked to is that left-right seems to be inverted, but should be a good starting point for what I saw on the <a href="http://youtu.be/eVcSCWetnTA" rel="noreferrer">YouTube video</a> linked in the question. The actions on the two views would have to be swaped. As shown in this piece of code (the 1st parameter to <code>mPager.setPageTransformer</code> should be <code>reverseDrawingOrder</code> = false). Note the middle 2 <code>if</code> sections are swaped and the <code>position</code> variable is handled slightly different to switch sides. The bouncy effect is left as an exercise. Please share when you get that!</p> <pre class="lang-java prettyprint-override"><code> package com.example.android.animationsdemo; import android.support.v4.view.ViewPager; import android.view.View; public class SinkPageTransformer implements ViewPager.PageTransformer { private static float MIN_SCALE = 0.75f; public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position &lt; -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(0); } else if (position &lt;= 0) { // [-1,0] // Fade the page out. view.setAlpha(1 + position); // Counteract the default slide transition view.setTranslationX(pageWidth * -position); // Scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } else if (position &lt;= 1) { // (0,1] // Use the default slide transition when moving to the left page view.setAlpha(1); view.setTranslationX(0); view.setScaleX(1); view.setScaleY(1); } else { // (1,+Infinity] // This page is way off-screen to the right. view.setAlpha(0); } } } </code></pre> <p>And just in case the page with the sample goes poof, here's that section's original code:</p> <pre class="lang-java prettyprint-override"><code> public class DepthPageTransformer implements ViewPager.PageTransformer { private static float MIN_SCALE = 0.75f; public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position &lt; -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(0); } else if (position &lt;= 0) { // [-1,0] // Use the default slide transition when moving to the left page view.setAlpha(1); view.setTranslationX(0); view.setScaleX(1); view.setScaleY(1); } else if (position &lt;= 1) { // (0,1] // Fade the page out. view.setAlpha(1 - position); // Counteract the default slide transition view.setTranslationX(pageWidth * -position); // Scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } else { // (1,+Infinity] // This page is way off-screen to the right. view.setAlpha(0); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload