Example usage for android.view View setScaleY

List of usage examples for android.view View setScaleY

Introduction

In this page you can find the example usage for android.view View setScaleY.

Prototype

public void setScaleY(float scaleY) 

Source Link

Document

Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width.

Usage

From source file:org.blanco.tests.viewpager.PageTransformer.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0.0f);//from   w  w  w .  j a va  2  s .  co m

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 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));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0.0f);
    }
}

From source file:me.panpf.tool4a.widget.ZoomOutPageTransformer.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//w  ww . j av a2  s  .c  o m
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();
    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);
    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to
        // shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 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));
    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:com.adkdevelopment.earthquakesurvival.ui.behaviour.ZoomOutPageTransformer.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);//from   w ww .  ja  v a  2s. co m

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 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));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:me.xiaopan.android.widget.ZoomOutPageTransformer.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//  w  w w .j  a  v  a 2s .  c  o m
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();
    if (position < -1) { // [-Infinity,-1)
                         // This page is way off-screen to the left.
        view.setAlpha(0);
    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to
        // shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 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));
    } else { // (1,+Infinity]
             // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:org.jraf.android.cinetoday.mobile.ui.ZoomOutPageTransformer.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) {
        // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);//from   w  w w .j  a v  a  2 s .c  o m
    } else if (position <= 1) {
        // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 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));
    } else {
        // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:com.grepsound.fragments.MyProfileFragment.java

private void interpolate(View view1, View view2, float interpolation) {
    getOnScreenRect(mRect1, view1);/*  w w  w . j  a  v  a 2  s  .c o m*/
    getOnScreenRect(mRect2, view2);

    float scaleX = 1.0F + interpolation * (mRect2.width() / mRect1.width() - 1.0F);
    float scaleY = 1.0F + interpolation * (mRect2.height() / mRect1.height() - 1.0F);
    float translationX = 0.5F * (interpolation * (mRect2.left + mRect2.right - mRect1.left - mRect1.right));
    float translationY = 0.5F * (interpolation * (mRect2.top + mRect2.bottom - mRect1.top - mRect1.bottom));

    view1.setTranslationX(translationX);
    view1.setTranslationY(translationY - mHeader.getTranslationY());
    view1.setScaleX(scaleX);
    view1.setScaleY(scaleY);
}

From source file:com.smartdengg.rxgallery.example.view.ScaleTransformer.java

@Override
public void transformPage(View page, float position) {

    /*//from   w  ww  . j  av  a 2  s .  c  o  m
    * http://stackoverflow.com/questions/23433027/onpagechangelistener-alpha-crossfading/23526632#23526632
    * http://andraskindler.com/blog/2013/create-viewpager-transitions-a-pagertransformer-example/
    * */
    int pageWidth = page.getWidth();
    int pageHeight = page.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(MIN_ALPHA);
    } else if (position < 0) { // [-1,0]
        // This page is moving out to the left

        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;

        page.setTranslationX(horzMargin - vertMargin / 2);
        page.setScaleX(scaleFactor);
        page.setScaleY(scaleFactor);
        page.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
    } else if (position <= 1) { //  (0,1]
        // This page is moving in from the right

        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        page.setTranslationX(-horzMargin + vertMargin / 2);

        page.setScaleX(scaleFactor);
        page.setScaleY(scaleFactor);
        page.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(MIN_ALPHA);
    }
}

From source file:la.marsave.fullscreentest.ZoomOutPageTransformer.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);//from   w ww.  ja  v  a2s  .co  m

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float MIN_SCALE = 0.85f;
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

        // Scale the page down (between MIN_SCALE and 1)
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

        // Fade the page relative to its size.
        float MIN_ALPHA = 0.5f;
        view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}

From source file:com.andrewsummers.otashu.DepthPageTransformer.java

/**
 * transformPage used to apply a custom transformation (animation) to page view scrolling.
 * // www . j a va 2s  .  c  o  m
 * @param view Incoming view.
 * @param position Current position of page relative to current "front and center" page. As per
 *            the official ViewPager documentation, possible values are: -1 is one page position
 *            to the left 0 is front and center. 1 is one page position to the right
 */
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    // if application touch feedback setting is set, enable touch feedback
    if (pref_touch_feedback_enabled) {
        view.setHapticFeedbackEnabled(true);
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    }

    // current page setting: [-Infinity, -1)
    if (position < -1) {
        // this page is way off-screen to the left
        view.setAlpha(0);
    }
    // current page setting: [-1, 0]
    else if (position <= 0) {
        // use the default slide transition when moving to the left page
        view.setAlpha(1);
        // view.setHapticFeedbackEnabled(hapticFeedbackEnabled);
        view.setTranslationY(pageWidth * position);
        view.setScaleX(1);
        view.setScaleY(1);
    }
    // current page setting: (0, 1)
    else if (position <= 1) {
        // fade page out
        view.setAlpha(1 - position);

        // counteract the default slide transition
        view.setTranslationY(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);
    }
    // current page setting: (1, +Infinity]
    else {
        // this page is way off-screen to the right
        view.setAlpha(0);
    }
}

From source file:ca.mymenuapp.ui.activities.RestaurantActivity.java

/**
 * Interpolate between two views./*  www . j  a  v  a  2s .  c om*/
 * This will animate view1 to somewhere between view1 and view2 dependening on the interpolation
 * value.
 * Used to translate the logo to the action bar icon.
 *
 * @param interpolation 'progress' of the interpolation
 */
private void interpolate(View view1, View view2, float interpolation) {
    getOnScreenRect(rectF1, view1);
    getOnScreenRect(rectF2, view2);

    float scaleX = 1.0F + interpolation * (rectF2.width() / rectF1.width() - 1.0F);
    float scaleY = 1.0F + interpolation * (rectF2.height() / rectF1.height() - 1.0F);
    float translationX = 0.5F * (interpolation * (rectF2.left + rectF2.right - rectF1.left - rectF1.right));
    float translationY = 0.5F * (interpolation * (rectF2.top + rectF2.bottom - rectF1.top - rectF1.bottom));

    view1.setTranslationX(translationX);
    view1.setTranslationY(translationY - restaurantHeader.getTranslationY());
    view1.setScaleX(scaleX);
    view1.setScaleY(scaleY);
}