Back to project page Swipe-Tabs.
The source code is released under:
MIT License
If you think the Android project Swipe-Tabs listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package it.bellotti.android.swipetabs.transforms; // w w w.ja v a2 s. c o m import android.support.v4.view.ViewPager; import android.view.View; /** * Created with IntelliJ IDEA. * User: Simone Bellotti * Date: 26/09/2014 * Time: 10.34 */ public abstract class BaseTransformer implements ViewPager.PageTransformer { /** * Called each {@link #transformPage(View, float)}. * * @param view * @param position */ protected abstract void onTransform(View view, float position); @Override public void transformPage(View view, float position) { onPreTransform(view, position); onTransform(view, position); onPostTransform(view, position); } /** * If the position offset of a fragment is less than negative one or greater than one, returning true will set the * visibility of the fragment to {@link View#GONE}. Returning false will force the fragment to {@link View#VISIBLE}. * * @return */ protected boolean hideOffscreenPages() { return true; } /** * Indicates if the default animations of the view pager should be used. * * @return */ protected boolean isPagingEnabled() { return false; } /** * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called. * * @param view * @param position */ protected void onPreTransform(View view, float position) { final float width = view.getWidth(); view.setRotationX(0); view.setRotationY(0); view.setRotation(0); view.setScaleX(1); view.setScaleY(1); view.setPivotX(0); view.setPivotY(0); view.setTranslationY(0); view.setTranslationX(isPagingEnabled() ? 0f : -width * position); if (hideOffscreenPages()) { view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f); } else { view.setAlpha(1f); } } /** * Called each {@link #transformPage(View, float)} call after {@link #onTransform(View, float)} is finished. * * @param view * @param position */ protected void onPostTransform(View view, float position) { } }