Java Code Examples for android.animation.PropertyValuesHolder#ofInt()
The following examples show how to use
android.animation.PropertyValuesHolder#ofInt() .
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: RippleAnimator.java From TheGlowingLoader with Apache License 2.0 | 6 votes |
public void startCircleMinor(final Callback callback) { PropertyValuesHolder rp2 = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius * .60f); PropertyValuesHolder ap2 = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp2 = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .06f), 0); ValueAnimator va2 = ValueAnimator.ofPropertyValuesHolder(rp2, ap2, sp2); va2.setInterpolator(new AccelerateInterpolator(.4f)); va2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius2 = (float) animation.getAnimatedValue("radius"); circleAlpha2 = (float) animation.getAnimatedValue("alpha"); circleStroke2 = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va2.setDuration(380); va2.start(); }
Example 2
Source File: ColorAnimation.java From Android-Image-Slider with Apache License 2.0 | 6 votes |
PropertyValuesHolder createColorPropertyHolder(boolean isReverse) { String propertyName; int colorStart; int colorEnd; if (isReverse) { propertyName = ANIMATION_COLOR_REVERSE; colorStart = this.colorEnd; colorEnd = this.colorStart; } else { propertyName = ANIMATION_COLOR; colorStart = this.colorStart; colorEnd = this.colorEnd; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, colorStart, colorEnd); holder.setEvaluator(new ArgbEvaluator()); return holder; }
Example 3
Source File: FillAnimation.java From Android-Image-Slider with Apache License 2.0 | 6 votes |
@NonNull private PropertyValuesHolder createRadiusPropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_RADIUS_REVERSE; startRadiusValue = radius / 2; endRadiusValue = radius; } else { propertyName = ANIMATION_RADIUS; startRadiusValue = radius; endRadiusValue = radius / 2; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 4
Source File: FillAnimation.java From Android-Image-Slider with Apache License 2.0 | 6 votes |
@NonNull private PropertyValuesHolder createStrokePropertyHolder(boolean isReverse) { String propertyName; int startStrokeValue; int endStrokeValue; if (isReverse) { propertyName = ANIMATION_STROKE_REVERSE; startStrokeValue = radius; endStrokeValue = 0; } else { propertyName = ANIMATION_STROKE; startStrokeValue = 0; endStrokeValue = radius; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startStrokeValue, endStrokeValue); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 5
Source File: ScaleDownAnimation.java From Android-Image-Slider with Apache License 2.0 | 6 votes |
@NonNull @Override protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_SCALE_REVERSE; startRadiusValue = (int) (radius * scaleFactor); endRadiusValue = radius; } else { propertyName = ANIMATION_SCALE; startRadiusValue = radius; endRadiusValue = (int) (radius * scaleFactor); } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 6
Source File: ScaleAnimation.java From Android-Image-Slider with Apache License 2.0 | 6 votes |
@NonNull protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_SCALE_REVERSE; startRadiusValue = radius; endRadiusValue = (int) (radius * scaleFactor); } else { propertyName = ANIMATION_SCALE; startRadiusValue = (int) (radius * scaleFactor); endRadiusValue = radius; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 7
Source File: PropertyAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
public void testPropertyValuesHolder(View v) { if (mTestSwitch) { PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 50f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 600f); // 同时进行X轴和Y轴的动画 ObjectAnimator xyAnimator = ObjectAnimator.ofPropertyValuesHolder(mTestPropertyValuesHolderBtn, pvhX, pvhY); xyAnimator.setDuration(C.Int.ANIM_DURATION * 2); xyAnimator.start(); } else { int left = v.getLeft(); int right = v.getRight(); // 将view左边增加10像素 PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", left, left + 10); // 将view右边减少10像素 PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", right, right - 10); // 在X轴缩放从原始比例1f,缩小到最小0f,再放大到原始比例1f PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f); // 在Y轴缩放从原始比例1f,缩小到最小0f,再放大到原始比例1f PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f); // 将PropertyValuesHolder交付给ObjectAnimator进行构建 ObjectAnimator customAnim = ObjectAnimator.ofPropertyValuesHolder(v, pvhLeft, pvhRight, pvhScaleX, pvhScaleY); customAnim.setDuration(C.Int.ANIM_DURATION * 2); customAnim.start(); } mTestSwitch = !mTestSwitch; }
Example 8
Source File: LayoutTransitionFragment.java From AndroidAll with Apache License 2.0 | 6 votes |
private LayoutTransition createTransitionChange() { LayoutTransition mTransitioner = new LayoutTransition(); //入场动画:view在这个容器中消失时触发的动画 ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 0f, 360f, 0f); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); //出场动画:view显示时的动画 ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotation", 0f, 90f, 0f); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 100, 0); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 0); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 0); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 0); Animator changeAppearAnimator = ObjectAnimator.ofPropertyValuesHolder(layoutTransitionGroup, pvhLeft, pvhTop, pvhRight, pvhBottom); mTransitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, changeAppearAnimator); /* 1, LayoutTransition.CHANGE_APPEARING/CHANGE_DISAPPEARING 必须配合PropertyValuesHolder使用才能有效果(使用ObjectAnimator无效). */ return mTransitioner; }
Example 9
Source File: EnterScreenAnimations.java From YCGallery with Apache License 2.0 | 6 votes |
/** * This method creates an animator that changes ImageView position on the screen. * It will look like view is translated from its position on previous screen to its new position on this screen */ @NonNull private ObjectAnimator createEnteringImagePositionAnimator() { PropertyValuesHolder propertyLeft = PropertyValuesHolder.ofInt("left", mAnimatedImage.getLeft(), mToLeft); PropertyValuesHolder propertyTop = PropertyValuesHolder.ofInt("top", mAnimatedImage.getTop(), mToTop - getStatusBarHeight()); PropertyValuesHolder propertyRight = PropertyValuesHolder.ofInt("right", mAnimatedImage.getRight(), mToLeft + mToWidth); PropertyValuesHolder propertyBottom = PropertyValuesHolder.ofInt("bottom", mAnimatedImage.getBottom(), mToTop + mToHeight - getStatusBarHeight()); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mAnimatedImage, propertyLeft, propertyTop, propertyRight, propertyBottom); animator.addListener(new SimpleAnimationListener() { @Override public void onAnimationEnd(Animator animation) { // set new parameters of animated ImageView. This will prevent blinking of view when set visibility to visible in Exit animation FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mAnimatedImage.getLayoutParams(); layoutParams.height = mImageTo.getHeight(); layoutParams.width = mImageTo.getWidth(); layoutParams.setMargins(mToLeft, mToTop - getStatusBarHeight(), 0, 0); } }); return animator; }
Example 10
Source File: ObjectAnimatorCompatBase.java From MaterialProgressBar with Apache License 2.0 | 5 votes |
@NonNull public static <T> ObjectAnimator ofInt(@Nullable T target, @NonNull Property<T, Integer> xProperty, @NonNull Property<T, Integer> yProperty, @NonNull Path path) { int[] xValues = new int[NUM_POINTS]; int[] yValues = new int[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofInt(xProperty, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofInt(yProperty, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
Example 11
Source File: PercentView.java From ClockView with Apache License 2.0 | 5 votes |
public void startCenterGunDong() { if (animatorCL != null && animatorCL.isRunning()) { return; } PropertyValuesHolder xLeftholder = PropertyValuesHolder.ofInt("scrollX", 0, 220); PropertyValuesHolder xRightholder = PropertyValuesHolder.ofInt("scrollX", 0, -220); animatorCL = ObjectAnimator.ofPropertyValuesHolder(center_iv_left, xLeftholder); animatorCR = ObjectAnimator.ofPropertyValuesHolder(center_iv_right, xRightholder); setAnimatorProperty(animatorCL); setAnimatorProperty(animatorCR); animatorCL.start(); animatorCR.start(); }
Example 12
Source File: PercentView.java From ClockView with Apache License 2.0 | 5 votes |
public void startLeftGunDong() { if (animatorL != null && animatorL.isRunning()) { return; } PropertyValuesHolder xholder = PropertyValuesHolder.ofInt("scrollX", 0, -220); animatorL = ObjectAnimator.ofPropertyValuesHolder(left_iv, xholder); setAnimatorProperty(animatorL); animatorL.start(); }
Example 13
Source File: ExitScreenAnimations.java From YCGallery with Apache License 2.0 | 5 votes |
/** * This method creates an animator that changes ImageView position on the screen. * It will look like view is translated from its position on this screen to its position on previous screen */ @NonNull private ObjectAnimator createExitingImagePositionAnimator() { // get initial location on the screen and start animation from there int[] locationOnScreen = new int[2]; mAnimatedImage.getLocationOnScreen(locationOnScreen); PropertyValuesHolder propertyLeft = PropertyValuesHolder.ofInt("left", locationOnScreen[0], mToLeft); PropertyValuesHolder propertyTop = PropertyValuesHolder.ofInt("top", locationOnScreen[1] - getStatusBarHeight(), mToTop - getStatusBarHeight()); PropertyValuesHolder propertyRight = PropertyValuesHolder.ofInt("right", locationOnScreen[0] + mAnimatedImage.getWidth(), mToLeft + mToWidth); PropertyValuesHolder propertyBottom = PropertyValuesHolder.ofInt("bottom", mAnimatedImage.getBottom(), mToTop + mToHeight - getStatusBarHeight()); return ObjectAnimator.ofPropertyValuesHolder(mAnimatedImage, propertyLeft, propertyTop, propertyRight, propertyBottom); }
Example 14
Source File: MovingViewAnimator.java From MovingImageView with Apache License 2.0 | 4 votes |
private PropertyValuesHolder createPropertyValuesHolder(String prop, float startValue, float endValue) { return PropertyValuesHolder.ofInt(prop, (int) startValue, (int) endValue); }
Example 15
Source File: AnimatedLinearLayout.java From MVPAndroidBootstrap with Apache License 2.0 | 4 votes |
private Animator prepareBoundsAnimator(View child, ChildBounds bounds) { int startLeft = bounds.start.left; int startTop = bounds.start.top; int startRight = bounds.start.right; int startBottom = bounds.start.bottom; int endLeft = bounds.end.left; int endTop = bounds.end.top; int endRight = bounds.end.right; int endBottom = bounds.end.bottom; int changeCount = 0; if (startLeft != endLeft) { child.setLeft(startLeft); changeCount++; } if (startTop != endTop) { child.setTop(startTop); changeCount++; } if (startRight != endRight) { child.setRight(startRight); changeCount++; } if (startBottom != endBottom) { child.setBottom(startBottom); changeCount++; } if (changeCount == 0) { return null; } PropertyValuesHolder pvh[] = new PropertyValuesHolder[changeCount]; int pvhIndex = -1; if (startLeft != endLeft) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("left", startLeft, endLeft); } if (startTop != endTop) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("top", startTop, endTop); } if (startRight != endRight) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("right", startRight, endRight); } if (startBottom != endBottom) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("bottom", startBottom, endBottom); } return ObjectAnimator.ofPropertyValuesHolder(child, pvh); }
Example 16
Source File: AnimatedLinearLayout.java From RxAndroidBootstrap with Apache License 2.0 | 4 votes |
private Animator prepareBoundsAnimator(View child, ChildBounds bounds) { int startLeft = bounds.start.left; int startTop = bounds.start.top; int startRight = bounds.start.right; int startBottom = bounds.start.bottom; int endLeft = bounds.end.left; int endTop = bounds.end.top; int endRight = bounds.end.right; int endBottom = bounds.end.bottom; int changeCount = 0; if (startLeft != endLeft) { child.setLeft(startLeft); changeCount++; } if (startTop != endTop) { child.setTop(startTop); changeCount++; } if (startRight != endRight) { child.setRight(startRight); changeCount++; } if (startBottom != endBottom) { child.setBottom(startBottom); changeCount++; } if (changeCount == 0) { return null; } PropertyValuesHolder pvh[] = new PropertyValuesHolder[changeCount]; int pvhIndex = -1; if (startLeft != endLeft) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("left", startLeft, endLeft); } if (startTop != endTop) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("top", startTop, endTop); } if (startRight != endRight) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("right", startRight, endRight); } if (startBottom != endBottom) { pvh[++pvhIndex] = PropertyValuesHolder.ofInt("bottom", startBottom, endBottom); } return ObjectAnimator.ofPropertyValuesHolder(child, pvh); }
Example 17
Source File: SlideAnimation.java From Android-Image-Slider with Apache License 2.0 | 4 votes |
private PropertyValuesHolder createSlidePropertyHolder() { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(ANIMATION_COORDINATE, coordinateStart, coordinateEnd); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 18
Source File: SwapAnimation.java From Android-Image-Slider with Apache License 2.0 | 4 votes |
private PropertyValuesHolder createColorPropertyHolder(String propertyName, int startValue, int endValue) { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startValue, endValue); holder.setEvaluator(new IntEvaluator()); return holder; }
Example 19
Source File: ShadowView.java From ZDepthShadow with MIT License | 4 votes |
protected void changeZDepth(ZDepth zDepth) { int newAlphaTopShadow = zDepth.getAlphaTopShadow(); int newAlphaBottomShadow = zDepth.getAlphaBottomShadow(); float newOffsetYTopShadow = zDepth.getOffsetYTopShadowPx(getContext()); float newOffsetYBottomShadow = zDepth.getOffsetYBottomShadowPx(getContext()); float newBlurTopShadow = zDepth.getBlurTopShadowPx(getContext()); float newBlurBottomShadow = zDepth.getBlurBottomShadowPx(getContext()); if (!mZDepthDoAnimation) { mZDepthParam.mAlphaTopShadow = newAlphaTopShadow; mZDepthParam.mAlphaBottomShadow = newAlphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = newOffsetYTopShadow; mZDepthParam.mOffsetYBottomShadowPx = newOffsetYBottomShadow; mZDepthParam.mBlurTopShadowPx = newBlurTopShadow; mZDepthParam.mBlurBottomShadowPx = newBlurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); return; } int nowAlphaTopShadow = mZDepthParam.mAlphaTopShadow; int nowAlphaBottomShadow = mZDepthParam.mAlphaBottomShadow; float nowOffsetYTopShadow = mZDepthParam.mOffsetYTopShadowPx; float nowOffsetYBottomShadow = mZDepthParam.mOffsetYBottomShadowPx; float nowBlurTopShadow = mZDepthParam.mBlurTopShadowPx; float nowBlurBottomShadow = mZDepthParam.mBlurBottomShadowPx; PropertyValuesHolder alphaTopShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_TOP_SHADOW, nowAlphaTopShadow, newAlphaTopShadow); PropertyValuesHolder alphaBottomShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW, nowAlphaBottomShadow, newAlphaBottomShadow); PropertyValuesHolder offsetTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_TOP_SHADOW, nowOffsetYTopShadow, newOffsetYTopShadow); PropertyValuesHolder offsetBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW, nowOffsetYBottomShadow, newOffsetYBottomShadow); PropertyValuesHolder blurTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_TOP_SHADOW, nowBlurTopShadow, newBlurTopShadow); PropertyValuesHolder blurBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW, nowBlurBottomShadow, newBlurBottomShadow); ValueAnimator anim = ValueAnimator .ofPropertyValuesHolder( alphaTopShadowHolder, alphaBottomShadowHolder, offsetTopShadowHolder, offsetBottomShadowHolder, blurTopShadowHolder, blurBottomShadowHolder); anim.setDuration(mZDepthAnimDuration); anim.setInterpolator(new LinearInterpolator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int alphaTopShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_TOP_SHADOW); int alphaBottomShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW); float offsetTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_TOP_SHADOW); float offsetBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW); float blurTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_TOP_SHADOW); float blurBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW); mZDepthParam.mAlphaTopShadow = alphaTopShadow; mZDepthParam.mAlphaBottomShadow = alphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = offsetTopShadow; mZDepthParam.mOffsetYBottomShadowPx = offsetBottomShadow; mZDepthParam.mBlurTopShadowPx = blurTopShadow; mZDepthParam.mBlurBottomShadowPx = blurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); } }); anim.start(); }
Example 20
Source File: BallSpinFade.java From crystal-preloaders with Apache License 2.0 | 3 votes |
@Override protected List<ValueAnimator> setupAnimation() { radiusValueHolder = PropertyValuesHolder.ofInt("radius", radius, 5); opacityValueHolder = PropertyValuesHolder.ofInt("opacity", 250, 20); for(int i = 0; i < valueAnimators.length; i++){ setAnimator(i); } return Arrays.asList(valueAnimators); }