Example usage for android.view View setPivotY

List of usage examples for android.view View setPivotY

Introduction

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

Prototype

public void setPivotY(float pivotY) 

Source Link

Document

Sets the y location of the point around which the view is #setRotation(float) rotated and #setScaleY(float) scaled .

Usage

From source file:com.wuzhanglao.niubi.utils.transformer.BaseTransformer.java

/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>//  w w  w  .j  a  v a  2 s  . co  m
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page     Apply the transformation to this page
 * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
 *                 center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    if (isPagingEnabled())
        page.setTranslationX(0f);
    else
        page.setTranslationX(-width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:banner.transformer.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>//  w  w w  .  j a va 2  s  . c  o  m
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        //         page.setEnabled(false);
    } else {
        //         page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.ruint.lib.viewpager.transforms.ABaseTransformer.java

/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>//from ww  w. ja v a 2  s  .c om
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 * 
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        page.setAlpha(1f);
    }
}

From source file:Anim.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>/* ww w . j a  v  a  2s  .c o  m*/
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.ljw.device3x.customview.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>//  w  w  w  .  j  a v  a  2s  .  c o  m
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
    page.setEnabled(true);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(true);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.howell.transformer.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>//from   w ww . j a va  2s .  com
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 * 
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
@SuppressWarnings("ResourceType")
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);

    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.dbeginc.dbweather.utils.animations.BasePageTransformer.java

/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>//ww  w  . j  a  va  2s.  co m
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page     Apply the transformation to this page
 * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
 *                 center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(final View page, final float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.runmit.sweedee.view.flippablestackview.StackPageTransformer.java

@Override
public void transformPage(View view, float position) {
    int dimen = view.getHeight();

    if (!mInitialValuesCalculated) {
        mInitialValuesCalculated = true;
        calculateInitialValues(dimen);/*  ww w  .j a v  a  2 s  .  c  o m*/
    }

    view.setRotationX(0);
    view.setPivotY(dimen / 2f);
    view.setPivotX(view.getWidth() / 2f);

    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));
        Log.d("position", "baseTranslation=" + baseTranslation + ",shiftTranslation=" + shiftTranslation
                + ",transY=" + (baseTranslation + shiftTranslation));
        view.setTranslationY(baseTranslation + shiftTranslation);
    } else if (position <= 1) {
        view.bringToFront();
        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);
        view.setPivotY(dimen);
        view.setRotationX(rotation);
        view.setScaleX(mZeroPositionScale);
        view.setScaleY(scale);
        view.setTranslationY(-baseTranslation - mBelowStackSpace - shiftTranslation);
    } else if (position > 1) {
        view.setAlpha(0f);
    }
}

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 2  s .c  o  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:com.animpagetransformer.transformer.AnimPageTransformer.java

/**
 * ?/*w  ww.j  a  v  a2  s  . c  om*/
 * 
 * @param page
 * @param position
 */
private void reset(View page, float position) {

    /* ?page? */
    mWidth = page.getWidth();
    mHeight = page.getHeight();

    /* ??page */
    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(0);
    page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
}