Java Code Examples for com.nineoldandroids.view.ViewHelper#setPivotY()

The following examples show how to use com.nineoldandroids.view.ViewHelper#setPivotY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JazzyViewPager.java    From school_shop with MIT License 6 votes vote down vote up
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example 2
Source File: FlexibleSpaceWithImageWithViewPagerTab2Activity.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
private void updateFlexibleSpace(float translationY) {
    ViewHelper.setTranslationY(mInterceptionLayout, translationY);
    int minOverlayTransitionY = getActionBarSize() - mOverlayView.getHeight();
    ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-translationY / 2, minOverlayTransitionY, 0));

    // Change alpha of overlay
    float flexibleRange = mFlexibleSpaceHeight - getActionBarSize();
    ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat(-translationY / flexibleRange, 0, 1));

    // Scale title text
    float scale = 1 + ScrollUtils.getFloat((flexibleRange + translationY - mTabHeight) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    setPivotXToTitle();
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, scale);
    ViewHelper.setScaleY(mTitleView, scale);
}
 
Example 3
Source File: CubeTransformer.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
public void transformPage(View view, float position) {
	if (position <= 0) {

		ViewHelper.setPivotX(view, view.getMeasuredWidth());
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		

		ViewHelper.setRotationY(view, 90f * position);
	} else if (position <= 1) {

		ViewHelper.setPivotX(view, 0);
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		ViewHelper.setRotationY(view, 90f * position);
	}
}
 
Example 4
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
private void setScaleDirection(int direction) {

		int screenWidth = getScreenWidth();
		float pivotX;
		float pivotY = getScreenHeight() * mScaleValue; // 0.5

		if (direction == DIRECTION_LEFT) {
			scrollViewMenu = scrollViewLeftMenu;
			pivotX = screenWidth * (mScaleValue + 1.0f);
		} else {
			scrollViewMenu = scrollViewRightMenu;
			pivotX = screenWidth * (mScaleValue - 1.0f);
		}

		ViewHelper.setPivotX(viewActivity, pivotX);
		ViewHelper.setPivotY(viewActivity, pivotY);
		ViewHelper.setPivotX(imageViewShadow, pivotX);
		ViewHelper.setPivotY(imageViewShadow, pivotY);
		scaleDirection = direction;
	}
 
Example 5
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
protected void animateTablet(View left, View right, float positionOffset) {		
		if (mState != State.IDLE) {
			if (left != null) {
				manageLayer(left, true);
				mRot = 30.0f * positionOffset;
				mTrans = getOffsetXForRotation(mRot, left.getMeasuredWidth(),
						left.getMeasuredHeight());
				ViewHelper.setPivotX(left, left.getMeasuredWidth()/2);
				ViewHelper.setPivotY(left, left.getMeasuredHeight()/2);
				ViewHelper.setTranslationX(left, mTrans);
				ViewHelper.setRotationY(left, mRot);
//				logState(left, "Left");
			}
			if (right != null) {
				manageLayer(right, true);
				mRot = -30.0f * (1-positionOffset);
				mTrans = getOffsetXForRotation(mRot, right.getMeasuredWidth(), 
						right.getMeasuredHeight());
				ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
				ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
				ViewHelper.setTranslationX(right, mTrans);
				ViewHelper.setRotationY(right, mRot);
//				logState(right, "Right");
			}
		}
	}
 
Example 6
Source File: ResideMenu.java    From iSCAU-Android with GNU General Public License v3.0 6 votes vote down vote up
private void setScaleDirection(int direction){

        int screenWidth = getScreenWidth();
        float pivotX;
        float pivotY = getScreenHeight() * 0.5f;

        if (direction == DIRECTION_LEFT){
            sv_menu = sv_left_menu;
            pivotX  = screenWidth * 1.5f;
        }else{
            sv_menu = sv_right_menu;
            pivotX  = screenWidth * -0.5f;
        }

        ViewHelper.setPivotX(view_activity, pivotX);
        ViewHelper.setPivotY(view_activity, pivotY);
        ViewHelper.setPivotX(iv_shadow, pivotX);
        ViewHelper.setPivotY(iv_shadow, pivotY);
        scaleDirection = direction;
    }
 
Example 7
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
private void setScaleDirection(int direction) {

		int screenWidth = getScreenWidth();
		float pivotX;
		float pivotY = getScreenHeight() * mScaleValue; // 0.5

		if (direction == DIRECTION_LEFT) {
			scrollViewMenu = scrollViewLeftMenu;
			pivotX = screenWidth * (mScaleValue + 1.0f);
		} else {
			scrollViewMenu = scrollViewRightMenu;
			pivotX = screenWidth * (mScaleValue - 1.0f);
		}

		ViewHelper.setPivotX(viewActivity, pivotX);
		ViewHelper.setPivotY(viewActivity, pivotY);
		ViewHelper.setPivotX(imageViewShadow, pivotX);
		ViewHelper.setPivotY(imageViewShadow, pivotY);
		scaleDirection = direction;
	}
 
Example 8
Source File: RotateDownTransformer.java    From FlycoBanner_Master with MIT License 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {
	final float width = page.getWidth();
	final float height = page.getHeight();
	final float rotation = ROT_MOD * position * -1.25f;

	ViewHelper.setPivotX(page,width * 0.5f);
       ViewHelper.setPivotY(page,height);
       ViewHelper.setRotation(page,rotation);
}
 
Example 9
Source File: JazzyViewPager.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void animateFlipVertical(View left, View right, float positionOffset, int positionOffsetPixels) {
    if (mState != State.IDLE) {
        if (left != null) {
            manageLayer(left, true);
            mRot = 180.0f * positionOffset;
            if (mRot > 90.0f) {
                left.setVisibility(View.INVISIBLE);
            } else {
                if (left.getVisibility() == View.INVISIBLE)
                    left.setVisibility(View.VISIBLE);
                mTrans = positionOffsetPixels;
                ViewHelper.setPivotX(left, left.getMeasuredWidth() * 0.5f);
                ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
                ViewHelper.setTranslationX(left, mTrans);
                ViewHelper.setRotationX(left, mRot);
            }
        }
        if (right != null) {
            manageLayer(right, true);
            mRot = -180.0f * (1 - positionOffset);
            if (mRot < -90.0f) {
                right.setVisibility(View.INVISIBLE);
            } else {
                if (right.getVisibility() == View.INVISIBLE)
                    right.setVisibility(View.VISIBLE);
                mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
                ViewHelper.setPivotX(right, right.getMeasuredWidth() * 0.5f);
                ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
                ViewHelper.setTranslationX(right, mTrans);
                ViewHelper.setRotationX(right, mRot);
            }
        }
    }
}
 
Example 10
Source File: CubeInTransformer.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	// Rotate the fragment on the left or right edge
       ViewHelper.setPivotX(view,position > 0 ? 0 : view.getWidth());
       ViewHelper.setPivotY(view,0);
       ViewHelper.setRotation(view,-90f * position);
}
 
Example 11
Source File: JazzyViewPager.java    From school_shop with MIT License 5 votes vote down vote up
protected void animateScroll(int position, float positionOffset) {
	if (mState != State.IDLE) {
		mRot = (float)(1-Math.cos(2*Math.PI*positionOffset))/2*30.0f;
		ViewHelper.setRotationY(this, mState == State.GOING_RIGHT ? mRot : -mRot);
		ViewHelper.setPivotX(this, getMeasuredWidth()*0.5f);
		ViewHelper.setPivotY(this, getMeasuredHeight()*0.5f);
	}
}
 
Example 12
Source File: RotateUpTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float rotation = ROT_MOD * position;

	ViewHelper.setPivotX(view,width * 0.5f);
       ViewHelper.setPivotY(view,0f);
       ViewHelper.setTranslationX(view,0f);
       ViewHelper.setRotation(view,rotation);
}
 
Example 13
Source File: ForegroundToBackgroundTransformer.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float height = view.getHeight();
	final float width = view.getWidth();
	final float scale = min(position > 0 ? 1f : Math.abs(1f + position), 0.5f);

	ViewHelper.setScaleX(view,scale);
       ViewHelper.setScaleY(view,scale);
       ViewHelper.setPivotX(view,width * 0.5f);
       ViewHelper.setPivotY(view,height * 0.5f);
       ViewHelper.setTranslationX(view,position > 0 ? width * position : -width * position * 0.25f);
}
 
Example 14
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 5 votes vote down vote up
private void animateFlipVertical(View left, View right, float positionOffset, int positionOffsetPixels) {
	if(mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = 180.0f * positionOffset;
			if (mRot > 90.0f) {
				left.setVisibility(View.INVISIBLE);
			} else {
				if (left.getVisibility() == View.INVISIBLE)
					left.setVisibility(View.VISIBLE);
				mTrans = positionOffsetPixels;
				ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
				ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
				ViewHelper.setTranslationX(left, mTrans);
				ViewHelper.setRotationX(left, mRot);
			}
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -180.0f * (1-positionOffset);
			if (mRot < -90.0f) {
				right.setVisibility(View.INVISIBLE);
			} else {
				if (right.getVisibility() == View.INVISIBLE)
					right.setVisibility(View.VISIBLE);
				mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
				ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
				ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
				ViewHelper.setTranslationX(right, mTrans);
				ViewHelper.setRotationX(right, mRot);
			}
		}
	}
}
 
Example 15
Source File: JazzyViewPager.java    From ClockView with Apache License 2.0 5 votes vote down vote up
private void animateCubeIn(View left, View right, float positionOffset)
{
	if (mState != State.IDLE)
	{
		if (left != null)
		{
			manageLayer(left, true);
			mRot = 90.0f * positionOffset;
			Log.e(TAG, "left.getMeasuredWidth()= " + left.getMeasuredWidth() + " ,left.getMeasuredHeight() = "
					+ left.getMeasuredHeight());

			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(left,1 - positionOffset);
			ViewHelper.setScaleY(left,1 - positionOffset);
			ViewHelper.setRotationY(left, mRot);
		}
		if (right != null)
		{
			manageLayer(right, true);
			mRot = -90.0f * (1 - positionOffset);
			Log.e(TAG, "right.getMeasuredWidth()= " + right.getMeasuredWidth() + " ,right.getMeasuredHeight() = "
					+ right.getMeasuredHeight());


			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(right,positionOffset);
			ViewHelper.setScaleY(right,positionOffset);
			ViewHelper.setRotationY(right, mRot);
		}
	}
}
 
Example 16
Source File: CaptureActivity.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
private void onCameraPreviewSuccess() {
    initCrop();
    captureErrorMask.setVisibility(View.GONE);

    ViewHelper.setPivotX(captureScanMask, 0.0f);
    ViewHelper.setPivotY(captureScanMask, 0.0f);

    mScanMaskObjectAnimator = ObjectAnimator.ofFloat(captureScanMask, "scaleY", 0.0f, 1.0f);
    mScanMaskObjectAnimator.setDuration(2000);
    mScanMaskObjectAnimator.setInterpolator(new DecelerateInterpolator());
    mScanMaskObjectAnimator.setRepeatCount(-1);
    mScanMaskObjectAnimator.setRepeatMode(ObjectAnimator.RESTART);
    mScanMaskObjectAnimator.start();
}
 
Example 17
Source File: FlipHorizontalTransformer.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float rotation = 180f * position;
       ViewHelper.setAlpha(view,rotation > 90f || rotation < -90f ? 0 : 1);
       ViewHelper.setPivotY(view,view.getHeight()*0.5f);
	ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
	ViewHelper.setRotationY(view,rotation);
}
 
Example 18
Source File: ZoomOutSlideTransformer.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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 vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = view.getWidth() * (1 - scaleFactor) / 2;

           // Center vertically
           ViewHelper.setPivotY(view,0.5f * height);


		if (position < 0) {
               ViewHelper.setTranslationX(view,horzMargin - vertMargin / 2);
		} else {
               ViewHelper.setTranslationX(view,-horzMargin + vertMargin / 2);
		}

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

		// Fade the page relative to its size.
           ViewHelper.setAlpha(view,MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 19
Source File: FanEffect.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void initView(View view, int i, int j)
{
    ViewHelper.setPivotX(view, 0.0F);
    ViewHelper.setPivotY(view, 0.0F);
    ViewHelper.setRotation(view, j * 70);
}
 
Example 20
Source File: JazzyViewPager.java    From ClockView with Apache License 2.0 4 votes vote down vote up
private void animateFlipVertical(View left, View right,
		float positionOffset, int positionOffsetPixels)
{
	if (mState != State.IDLE)
	{
		if (left != null)
		{
			manageLayer(left, true);
			mRot = 180.0f * positionOffset;
			if (mRot > 90.0f)
			{
				left.setVisibility(View.INVISIBLE);
			} else
			{
				if (left.getVisibility() == View.INVISIBLE)
					left.setVisibility(View.VISIBLE);
				mTrans = positionOffsetPixels;
				ViewHelper.setPivotX(left, left.getMeasuredWidth() * 0.5f);
				ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
				ViewHelper.setTranslationX(left, mTrans);
				ViewHelper.setRotationX(left, mRot);
			}
		}
		if (right != null)
		{
			manageLayer(right, true);
			mRot = -180.0f * (1 - positionOffset);
			if (mRot < -90.0f)
			{
				right.setVisibility(View.INVISIBLE);
			} else
			{
				if (right.getVisibility() == View.INVISIBLE)
					right.setVisibility(View.VISIBLE);
				mTrans = -getWidth() - getPageMargin()
						+ positionOffsetPixels;
				ViewHelper
						.setPivotX(right, right.getMeasuredWidth() * 0.5f);
				ViewHelper.setPivotY(right,
						right.getMeasuredHeight() * 0.5f);
				ViewHelper.setTranslationX(right, mTrans);
				ViewHelper.setRotationX(right, mRot);
			}
		}
	}
}