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 . j a v a2 s.c o m import android.view.View; /** * Created with IntelliJ IDEA. * User: SimoneBellotti * Date: 24/11/2014 * Time: 13.13 */ public class ZoomOutSlideTransformer extends BaseTransformer { private static final float MIN_SCALE = 0.85f; private static final float MIN_ALPHA = 0.5f; @Override protected void onTransform(View view, float position) { if (position >= -1 || position <= 1) { // Modify the default slide transition to shrink the page as well final float height = view.getHeight(); final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); final float verticalMargin = height * (1 - scaleFactor) / 2; final float horizontalMargin = view.getWidth() * (1 - scaleFactor) / 2; // Center vertically view.setPivotY(0.5f * height); if (position < 0) { view.setTranslationX(horizontalMargin - verticalMargin / 2); } else { view.setTranslationX(-horizontalMargin + verticalMargin / 2); } // Scale the page down (between MIN_SCALE and 1) view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); // Fade the page relative to its size. view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); } } }