Java Code Examples for android.view.View#setPivotY()

The following examples show how to use android.view.View#setPivotY() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
	 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
	 * <p>
	 * 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);
		}
	}
 
Example 2
/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)} is called.
 * 
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
	final float width = view.getWidth();

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

	if (hideOffscreenPages()) {
		view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
	} else {
		view.setAlpha(1f);
	}
}
 
Example 3
Source Project: Trebuchet   File: Rotate.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void screenScrolled(View v, float progress) {
    float rotation =
            (rotateUp ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * progress;

    float translationX = v.getMeasuredWidth() * progress;

    float rotatePoint =
            (v.getMeasuredWidth() * 0.5f)
                    / (float) Math.tan(Math.toRadians((double) (TRANSITION_SCREEN_ROTATION * 0.5f)));

    v.setPivotX(v.getMeasuredWidth() * 0.5f);
    if (rotateUp) {
        v.setPivotY(-rotatePoint);
    } else {
        v.setPivotY(v.getMeasuredHeight() + rotatePoint);
    }
    v.setRotation(rotation);
    v.setTranslationX(translationX);
}
 
Example 4
private void hideHint(final View view) {
    view.setPivotX(0);
    view.setPivotY(view.getHeight());

    Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f));
    iconAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.INVISIBLE);
        }
    });
    iconAnim.start();
}
 
Example 5
Source Project: EasyTabs   File: EasyZoomInTransformer.java    License: MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
 
Example 6
@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);

    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(width * 0.5f);
    view.setPivotY(height * 0.5f);
    view.setTranslationX(position > 0 ? width * position : -width * position * 0.25f);
}
 
Example 7
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float height = view.getHeight();
	final float rotation = ROT_MOD * position * -1.25f;

	view.setPivotX(width * 0.5f);
	view.setPivotY(height);
	view.setRotation(rotation);
}
 
Example 8
Source Project: RxTools-master   File: RxAnimationTool.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 放大动画
 *
 * @param view
 */
public static void zoomOut(final View view, float scale) {
    view.setPivotY(view.getHeight());
    view.setPivotX(view.getWidth() / 2);
    AnimatorSet mAnimatorSet = new AnimatorSet();

    ObjectAnimator mAnimatorScaleX = ObjectAnimator.ofFloat(view, "scaleX", scale, 1.0f);
    ObjectAnimator mAnimatorScaleY = ObjectAnimator.ofFloat(view, "scaleY", scale, 1.0f);
    ObjectAnimator mAnimatorTranslateY = ObjectAnimator.ofFloat(view, "translationY", view.getTranslationY(), 0);

    mAnimatorSet.play(mAnimatorTranslateY).with(mAnimatorScaleX);
    mAnimatorSet.play(mAnimatorScaleX).with(mAnimatorScaleY);
    mAnimatorSet.setDuration(300);
    mAnimatorSet.start();
}
 
Example 9
Source Project: carouselview   File: CoverFlowViewTransformer.java    License: MIT License 5 votes vote down vote up
@Override
public void transform(View view, float position) {
    int width = view.getMeasuredWidth(), height = view.getMeasuredHeight();
    view.setPivotX(width / 2.0f);
    view.setPivotY(height / 2.0f);
    view.setTranslationX(width * position * mOffsetXPercent);
    view.setRotationY(Math.signum(position) * (float)(Math.log(Math.abs(position) + 1) / Math.log(3) * - mYProjection));
    view.setScaleY(1 + mScaleYFactor * Math.abs(position));
}
 
Example 10
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
 
Example 11
@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 width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

		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));
	}
}
 
Example 12
Source Project: FoldableLayout   File: UnfoldableView.java    License: Apache License 2.0 5 votes vote down vote up
void setView(View view, int width, int height) {
    LayoutParams params = new LayoutParams(width, height, Gravity.CENTER_HORIZONTAL);
    addView(view, params);

    // Setting temporary pivotal point, see #onMeasure()
    origPivotY = view.getPivotY();
    view.setPivotY(0f);
}
 
Example 13
Source Project: HomeApplianceMall   File: ZoomInTransformer.java    License: MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
 
Example 14
@Override
protected void onTransform(View view, float position) {
	final float rotation = -180f * position;

	view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationX(rotation);
}
 
Example 15
Source Project: JazzyListView   File: GrowEffect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initView(View item, int position, int scrollDirection) {
    item.setPivotX(item.getWidth() / 2);
    item.setPivotY(item.getHeight() / 2);
    item.setScaleX(INITIAL_SCALE_FACTOR);
    item.setScaleY(INITIAL_SCALE_FACTOR);
}
 
Example 16
Source Project: Banner   File: ZoomOutTranformer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    final float scale = 1f + Math.abs(position);
    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(view.getWidth() * 0.5f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
    if (position == -1) {
        view.setTranslationX(view.getWidth() * -1);
    }
}
 
Example 17
Source Project: Banner   File: RotateDownTransformer.java    License: 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 height = view.getHeight();
    final float rotation = ROT_MOD * position * -1.25f;

    view.setPivotX(width * 0.5f);
    view.setPivotY(height);
    view.setRotation(rotation);
}
 
Example 18
Source Project: EasyTabs   File: EasyCubeInTransformer.java    License: 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
	view.setPivotX(position > 0 ? 0 : view.getWidth());
	view.setPivotY(0);
	view.setRotationY(-90f * position);
}
 
Example 19
@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 width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

		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));
	}
}
 
Example 20
@Override
   protected void onTransform(View view, float position) {
	view.setPivotX(position < 0f ? view.getWidth() : 0f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationY(90f * position);
}