Example usage for android.view View setRotationY

List of usage examples for android.view View setRotationY

Introduction

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

Prototype

public void setRotationY(float rotationY) 

Source Link

Document

Sets the degrees that the view is rotated around the vertical axis through the pivot point.

Usage

From source file:com.tmall.ultraviewpager.transformer.UltraDepthScaleTransformer.java

@Override
public void transformPage(View view, float position) {
    final float scale = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
    final float rotation = MAX_ROTATION * Math.abs(position);

    if (position <= 0f) {
        view.setTranslationX(view.getWidth() * -position * 0.19f);
        view.setPivotY(0.5f * view.getHeight());
        view.setPivotX(0.5f * view.getWidth());
        view.setScaleX(scale);//from  w w  w  . ja va2s. co  m
        view.setScaleY(scale);
        view.setRotationY(rotation);
    } else if (position <= 1f) {
        view.setTranslationX(view.getWidth() * -position * 0.19f);
        view.setPivotY(0.5f * view.getHeight());
        view.setPivotX(0.5f * view.getWidth());
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setRotationY(-rotation);
    }
}

From source file:com.amaze.filemanager.utils.FlipAnim.java

public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);//from w w w . j ava  2  s .  c  o  m
    } else if (position <= 0) { // [-1,0]
        // Use the default slide transition when moving to the left page
        view.setAlpha(1);
        view.setTranslationY(0);
        //   view.setRotationX(Math.round(360*position));
        view.setRotationY(Math.round(360 * position));
        view.setScaleX(1 + position);
        view.setScaleY(1 + position);
    } else if (position <= 1) { // (0,1]
        // Fade the page out.
        view.setAlpha(1 - position);
        // Counteract the default slide transition
        view.setTranslationY(pageWidth * position * position);
        view.setTranslationX(pageWidth * position * position);
        //   view.setRotationX(Math.round(360*position));
        view.setRotationY(Math.round(360 * position));
        // Scale the page down (between MIN_SCALE and 1)

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

From source file:com.suyonoion.loginexpanded.ExpandedViewpagerUI.java

public ExpandedViewpagerUI(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!isInEditMode()) {
        // array List string , daftar list judul
        List<String> mengisi_Tempat_judul = new ArrayList<>();
        /* judul page1/*from   w  ww  .j  a  v a 2s  .  co m*/
        * listjudul.tambahkan(dapakandarifolderRes.dapatkanStringDari(name="str_notifikasi",bertype="string")
        * */
        mengisi_Tempat_judul.add(getResources().getString(setResource("str_notifikasi", "string")));
        /* judul page2
        * listjudul.tambahkan(dapakandarifolderRes.dapatkanStringDari(name="str_page2",bertype="string")
        * */
        mengisi_Tempat_judul.add(getResources().getString(setResource("str_page2", "string")));
        /* judul page3
        * listjudul.tambahkan(dapakandarifolderRes.dapatkanStringDari(name="str_page3",bertype="string")
        * */
        mengisi_Tempat_judul.add(getResources().getString(setResource("str_page3", "string")));

        //mengisi_Tempat_judul masukkan ke adapter
        AdapterExpandedViewpagerUI adapter = new AdapterExpandedViewpagerUI(mengisi_Tempat_judul);
        // Viewpager id = temukan target view menurut id-nya
        final ViewPager EasyExpandedViewPagerUI = (ViewPager) this
                .findViewById(setResource("id_viewpager", "id"));
        // membuat pageTransformer/efek transisi
        PageTransformer animasi = new PageTransformer() {
            @TargetApi(Build.VERSION_CODES.HONEYCOMB) //target api
            @Override
            public void transformPage(View view, float position) {
                float ion = Float.valueOf("90"); //rotasi 90 derajat
                final float rotation = (position < 0 ? ion : -ion) * Math.abs(position);
                view.setAlpha(rotation > ion || rotation < -ion ? 0f : 1f);
                view.setPivotX(position < 0f ? view.getWidth() : 0f);
                view.setPivotY(view.getHeight() * 0.5f);
                view.setRotationY(ion * position);
            }
        };
        //setPageTransformer Viewpagernya = animasi
        EasyExpandedViewPagerUI.setPageTransformer(true, animasi);
        EasyExpandedViewPagerUI.setAdapter(adapter);
        EasyExpandedViewPagerUI.setOffscreenPageLimit(3); //jumlah limit pages = 3
    }
}

From source file:edward.com.recyclerview.BaseItemAnimator.java

void reset(View v) {
    v.setAlpha(1);//from   w ww. j  av a  2 s. co m
    v.setScaleY(1);
    v.setScaleX(1);
    v.setTranslationY(0);
    v.setTranslationX(0);
    v.setRotation(0);
    v.setRotationY(0);
    v.setRotationX(0);
    v.setPivotX(v.getMeasuredWidth() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);
    v.animate().setInterpolator(null);
}

From source file:android.improving.utils.views.cardsview.StackPageTransformer.java

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

    int dimen = 0;
    switch (mOrientation) {
    case VERTICAL:
        dimen = view.getHeight();/*  www  .j  ava  2  s  .  c om*/
        break;
    case HORIZONTAL:
        dimen = view.getWidth();
        break;
    }

    if (!mInitialValuesCalculated) {
        mInitialValuesCalculated = true;
        calculateInitialValues(dimen);
    }

    switch (mOrientation) {
    case VERTICAL:
        view.setRotationX(0);
        view.setPivotY(dimen / 2f);
        view.setPivotX(view.getWidth() / 2f);
        break;
    case HORIZONTAL:
        view.setRotationY(0);
        view.setPivotX(dimen / 2f);
        view.setPivotY(view.getHeight() / 2f);
        break;
    }

    if (position < -mNumberOfStacked - 1) {
        view.setAlpha(0f);
    } else if (position <= 0) {
        float scale = mZeroPositionScale + (position * mStackedScaleFactor);
        float baseTranslation = (-position * dimen);
        float shiftTranslation = calculateShiftForScale(position, scale, dimen);
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setAlpha(1.0f + (position * mAlphaFactor));
        switch (mOrientation) {
        case VERTICAL:
            view.setTranslationY(baseTranslation + shiftTranslation);
            break;
        case HORIZONTAL:
            view.setTranslationX(baseTranslation + shiftTranslation);
            break;
        }
    } else if (position <= 1) {
        float scale = mZeroPositionScale + (position * mStackedScaleFactor);
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setAlpha(1.0f + (position * mAlphaFactor));
        view.setTranslationY(position);
    } else if (position > 1) {
        view.setAlpha(0f);
    }
}

From source file:cn.edu.nuc.seeworld.view.flippablestackview.StackPageTransformer.java

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

    int dimen = 0;
    switch (mOrientation) {
    case VERTICAL:
        dimen = view.getHeight();//from   ww  w  . j  a v a2  s. c o  m
        break;
    case HORIZONTAL:
        dimen = view.getWidth();
        break;
    }

    if (!mInitialValuesCalculated) {
        mInitialValuesCalculated = true;
        calculateInitialValues(dimen);
    }

    switch (mOrientation) {
    case VERTICAL:
        view.setRotationX(0);
        view.setPivotY(dimen / 2f);
        view.setPivotX(view.getWidth() / 2f);
        break;
    case HORIZONTAL:
        view.setRotationY(0);
        view.setPivotX(dimen / 2f);
        view.setPivotY(view.getHeight() / 2f);
        break;
    }

    if (position < -mNumberOfStacked - 1) {
        view.setAlpha(0f);
    } else if (position <= 0) {
        float scale = mZeroPositionScale + (position * mStackedScaleFactor);
        float baseTranslation = (-position * dimen);
        float shiftTranslation = calculateShiftForScale(position, scale, dimen);
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setAlpha(1.0f + (position * mAlphaFactor));
        switch (mOrientation) {
        case VERTICAL:
            view.setTranslationY(baseTranslation + shiftTranslation);
            break;
        case HORIZONTAL:
            view.setTranslationX(baseTranslation + shiftTranslation);
            break;
        }
    } else if (position <= 1) {
        float baseTranslation = position * dimen;
        float scale = mZeroPositionScale
                - mValueInterpolator.map(mScaleInterpolator.getInterpolation(position));
        scale = (scale < 0) ? 0f : scale;
        float shiftTranslation = (1.0f - position) * mOverlap;
        float rotation = -mRotationInterpolator.getInterpolation(position) * 90;
        rotation = (rotation < -90) ? -90 : rotation;
        float alpha = 1.0f - position;
        alpha = (alpha < 0) ? 0f : alpha;
        view.setAlpha(alpha);
        switch (mOrientation) {
        case VERTICAL:
            view.setPivotY(dimen);
            view.setRotationX(rotation);
            view.setScaleX(mZeroPositionScale);
            view.setScaleY(scale);
            view.setTranslationY(-baseTranslation - mBelowStackSpace - shiftTranslation);
            break;
        case HORIZONTAL:
            view.setPivotX(dimen);
            view.setRotationY(-rotation);
            view.setScaleY(mZeroPositionScale);
            view.setScaleX(scale);
            view.setTranslationX(-baseTranslation - mBelowStackSpace - shiftTranslation);
            break;
        }
    } else if (position > 1) {
        view.setAlpha(0f);
    }
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();

    mUseTransitionEffect = !isInOverviewMode() && !mIsSwitchingState;

    updatePageAlphaValues(screenCenter);

    super.screenScrolled(screenCenter);

    enableHwLayersOnVisiblePages();/*  ww w.ja  v a 2  s  . co  m*/

    boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;

    if (isInOverscroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.35f;
        final float rightBiasedPivot = 0.65f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        View v = getPageAt(index);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            v.setCameraDistance(mDensity * mCameraDistance);
            v.setPivotX(v.getMeasuredWidth() * pivotX);
        }

        float scrollProgress = getScrollProgress(screenCenter, v, index);
        float rotation = -TRANSITION_MAX_ROTATION * scrollProgress;
        v.setRotationY(rotation);
    } else {
        if (mOverscrollTransformsSet) {
            mOverscrollTransformsSet = false;
            View v0 = getPageAt(mCurrentPage);
            v0.setRotationY(0);
            v0.setCameraDistance(mDensity * mCameraDistance);
            v0.setPivotX(v0.getMeasuredWidth() / 2);
            v0.setPivotY(v0.getMeasuredHeight() / 2);
        }
    }
}

From source file:us.shandian.launcher.Page.java

public void setTransitionEffect(TransitionEffect effect) {
    mTransitionEffect = effect;/* w  w w  . j  a va  2s .c o m*/

    // Reset
    if (mScrollTransformsSet) {
        for (int i = 0; i < getChildCount(); i++) {
            View v = getPageAt(i);

            if (v != null) {
                v.setPivotX(v.getMeasuredWidth() * 0.5f);
                v.setPivotY(v.getMeasuredHeight() * 0.5f);
                v.setRotation(0);
                v.setRotationX(0);
                v.setRotationY(0);
                v.setScaleX(1f);
                v.setScaleY(1f);
                v.setTranslationX(0f);
                v.setTranslationY(0f);
                v.setVisibility(VISIBLE);
                setChildAlpha(v, 1f);
            }
        }
    }

    mScrollTransformsSet = false;
}

From source file:com.android.launcher2.AsyncTaskCallback.java

@Override
protected void screenScrolled(int screenCenter) {
    super.screenScrolled(screenCenter);

    for (int i = 0; i < getChildCount(); i++) {
        View v = getPageAt(i);
        if (v != null) {
            float scrollProgress = getScrollProgress(screenCenter, v, i);

            float interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
            float scale = (1 - interpolatedProgress) + interpolatedProgress * TRANSITION_SCALE_FACTOR;
            float translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth();

            float alpha;

            if (scrollProgress < 0) {
                alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(1 - Math.abs(scrollProgress))
                        : 1.0f;/*w  w w .  j  a v a 2 s .co m*/
            } else {
                // On large screens we need to fade the page as it nears its leftmost position
                alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
            }

            v.setCameraDistance(mDensity * CAMERA_DISTANCE);
            int pageWidth = v.getMeasuredWidth();
            int pageHeight = v.getMeasuredHeight();

            if (PERFORM_OVERSCROLL_ROTATION) {
                if (i == 0 && scrollProgress < 0) {
                    // Overscroll to the left
                    v.setPivotX(TRANSITION_PIVOT * pageWidth);
                    v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
                    scale = 1.0f;
                    alpha = 1.0f;
                    // On the first page, we don't want the page to have any lateral motion
                    translationX = 0;
                } else if (i == getChildCount() - 1 && scrollProgress > 0) {
                    // Overscroll to the right
                    v.setPivotX((1 - TRANSITION_PIVOT) * pageWidth);
                    v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
                    scale = 1.0f;
                    alpha = 1.0f;
                    // On the last page, we don't want the page to have any lateral motion.
                    translationX = 0;
                } else {
                    v.setPivotY(pageHeight / 2.0f);
                    v.setPivotX(pageWidth / 2.0f);
                    v.setRotationY(0f);
                }
            }

            v.setTranslationX(translationX);
            v.setScaleX(scale);
            v.setScaleY(scale);
            v.setAlpha(alpha);

            // If the view has 0 alpha, we set it to be invisible so as to prevent
            // it from accepting touches
            if (alpha == 0) {
                v.setVisibility(INVISIBLE);
            } else if (v.getVisibility() != VISIBLE) {
                v.setVisibility(VISIBLE);
            }
        }
    }
}

From source file:us.shandian.launcher.Page.java

protected void screenScrolled(int screenCenter) {
    boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;

    if (mFadeInAdjacentScreens || mTransitionEffect != null || mScrollTransformsSet) {
        for (int i = 0; i < getChildCount(); i++) {
            View v = getPageAt(i);
            if (v != null) {
                float scrollProgress = getScrollProgress(screenCenter, v, i);

                if (Math.abs(scrollProgress) >= 1f) {
                    v.setCameraDistance(0);
                }//from   www. java  2s .  c o m

                if (mTransitionEffect != null && !isInOverscroll) {
                    mTransitionEffect.screenScrolled(v, i, scrollProgress);
                } else if (mScrollTransformsSet) {
                    v.setPivotX(v.getMeasuredWidth() * 0.5f);
                    v.setPivotY(v.getMeasuredHeight() * 0.5f);
                    v.setRotation(0);
                    v.setRotationX(0);
                    v.setRotationY(0);
                    v.setScaleX(1f);
                    v.setScaleY(1f);
                    v.setTranslationX(0f);
                    v.setTranslationY(0f);
                    v.setVisibility(VISIBLE);
                    setChildAlpha(v, 1f);
                }
            }
        }
        mScrollTransformsSet = mTransitionEffect != null && !isInOverscroll;
    }
}