Created
February 27, 2015 14:17
-
-
Save wasabeef/15aec840fd35d1bdc93b to your computer and use it in GitHub Desktop.
Better Sliding ViewPager.PageTransformer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.co.cyberagent.madrid.ui.adapter.transformer; | |
import android.support.v4.view.ViewPager; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* Created by Daichi Furiya on 2015/02/27. | |
*/ | |
public class MockTransformer implements ViewPager.PageTransformer { | |
@Override | |
public void transformPage(View page, float position) { | |
if (position <= 0) { | |
int pageWidth = page.getWidth(); | |
float translateValue = position * -pageWidth; | |
if (translateValue > -pageWidth) { | |
page.setTranslationX(translateValue); | |
} else { | |
page.setTranslationX(0); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment