android.view.animation.Interpolator Java Examples
The following examples show how to use
android.view.animation.Interpolator.
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: DirectionalViewPager.java From YCScrollPager with Apache License 2.0 | 6 votes |
/** * 设置viewPager滑动动画持续时间 * API>19 */ @TargetApi(Build.VERSION_CODES.KITKAT) public void setAnimationDuration(final int during){ try { // viewPager平移动画事件 Field mField = ViewPager.class.getDeclaredField("mScroller"); mField.setAccessible(true); // 动画效果与ViewPager的一致 Interpolator interpolator = new Interpolator() { @Override public float getInterpolation(float t) { t -= 1.0f; return t * t * t * t * t + 1.0f; } }; FixedSpeedScroller scroller = new FixedSpeedScroller(getContext(), interpolator, mRecentTouchTime); scroller.setDuration(during); mField.set(this, scroller); } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) { e.printStackTrace(); } }
Example #2
Source File: AnimationOrAnimator.java From scene with Apache License 2.0 | 6 votes |
private void reverse(Animation animation) { Interpolator interpolator = animation.getInterpolator(); if (interpolator != null) { if (interpolator instanceof ReverseInterpolator) { animation.setInterpolator(((ReverseInterpolator) interpolator).delegate); } else { animation.setInterpolator(new ReverseInterpolator(interpolator)); } } else { animation.setInterpolator(new ReverseInterpolator()); } if (animation instanceof AnimationSet) { List<Animation> animationList = ((AnimationSet) animation).getAnimations(); for (int i = 0; i < animationList.size(); i++) { reverse(animationList.get(i)); } } }
Example #3
Source File: PhoneTabSwitcherLayout.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Creates and returns a layout listener, which allows to start a peek animation to add a tab, * once its view has been inflated. * * @param item * The item, which corresponds to the tab, which should be added, as an instance of the * class {@link AbstractItem}. The item may not be null * @param peekAnimation * The peek animation, which should be started, as an instance of the class {@link * PeekAnimation}. The peek animation may not be null * @return The listener, which has been created, as an instance of the type {@link * OnGlobalLayoutListener}. The listener may not be null */ private OnGlobalLayoutListener createPeekLayoutListener(@NonNull final AbstractItem item, @NonNull final PeekAnimation peekAnimation) { return new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { long totalDuration = peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() : peekAnimationDuration; long duration = totalDuration / 3; Interpolator interpolator = peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() : new AccelerateDecelerateInterpolator(); float peekPosition = getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false) * 0.66f; animatePeek(item, duration, interpolator, peekPosition, peekAnimation); } }; }
Example #4
Source File: RippleDrawable.java From MDPreference with Apache License 2.0 | 5 votes |
private RippleDrawable(Drawable backgroundDrawable, int backgroundAnimDuration, int backgroundColor, int rippleType, int delayClickType, int maxRippleRadius, int rippleAnimDuration, int rippleColor, Interpolator inInterpolator, Interpolator outInterpolator, int type, int topLeftCornerRadius, int topRightCornerRadius, int bottomRightCornerRadius, int bottomLeftCornerRadius, int left, int top, int right, int bottom){ setBackgroundDrawable(backgroundDrawable); mBackgroundAnimDuration = backgroundAnimDuration; mBackgroundColor = backgroundColor; mRippleType = rippleType; setDelayClickType(delayClickType); mMaxRippleRadius = maxRippleRadius; mRippleAnimDuration = rippleAnimDuration; mRippleColor = rippleColor; if(mRippleType == TYPE_TOUCH && mMaxRippleRadius <= 0) mRippleType = TYPE_TOUCH_MATCH_VIEW; mInInterpolator = inInterpolator; mOutInterpolator = outInterpolator; setMask(type, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, left, top, right, bottom); mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mFillPaint.setStyle(Paint.Style.FILL); mShaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mShaderPaint.setStyle(Paint.Style.FILL); mBackground = new Path(); mBackgroundBounds = new RectF(); mRipplePoint = new PointF(); mMatrix = new Matrix(); mInShader = new RadialGradient(0, 0, GRADIENT_RADIUS, new int[]{mRippleColor, mRippleColor, 0}, GRADIENT_STOPS, Shader.TileMode.CLAMP); if(mRippleType == TYPE_WAVE) mOutShader = new RadialGradient(0, 0, GRADIENT_RADIUS, new int[]{0, ColorUtil.getColor(mRippleColor, 0f), mRippleColor}, GRADIENT_STOPS, Shader.TileMode.CLAMP); }
Example #5
Source File: CollapsingTextHelper.java From android-proguards with Apache License 2.0 | 5 votes |
private static float lerp(float startValue, float endValue, float fraction, Interpolator interpolator) { if (interpolator != null) { fraction = interpolator.getInterpolation(fraction); } return AnimUtils.lerp(startValue, endValue, fraction); }
Example #6
Source File: MarkerAnimationActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 屏幕中心marker 跳动 */ public void startJumpAnimation() { if (screenMarker != null ) { //根据屏幕距离计算需要移动的目标点 final LatLng latLng = screenMarker.getPosition(); Point point = aMap.getProjection().toScreenLocation(latLng); point.y -= dip2px(this,125); LatLng target = aMap.getProjection() .fromScreenLocation(point); //使用TranslateAnimation,填写一个需要移动的目标点 Animation animation = new TranslateAnimation(target); animation.setInterpolator(new Interpolator() { @Override public float getInterpolation(float input) { // 模拟重加速度的interpolator if(input <= 0.5) { return (float) (0.5f - 2 * (0.5 - input) * (0.5 - input)); } else { return (float) (0.5f - Math.sqrt((input - 0.5f)*(1.5f - input))); } } }); //整个移动所需要的时间 animation.setDuration(600); //设置动画 screenMarker.setAnimation(animation); //开始动画 screenMarker.startAnimation(); } else { Log.e("amap","screenMarker is null"); } }
Example #7
Source File: CanvasTransformerBuilder.java From WeatherStream with Apache License 2.0 | 5 votes |
public CanvasTransformer zoom(final int openedX, final int closedX, final int openedY, final int closedY, final int px, final int py, final Interpolator interp) { initTransformer(); mTrans = new CanvasTransformer() { public void transformCanvas(Canvas canvas, float percentOpen) { mTrans.transformCanvas(canvas, percentOpen); float f = interp.getInterpolation(percentOpen); canvas.scale((openedX - closedX) * f + closedX, (openedY - closedY) * f + closedY, px, py); } }; return mTrans; }
Example #8
Source File: UDInterpolator.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
public static Interpolator parse(Integer type, Float cycles) { if (type != null) { switch (type) { case 0: return new AccelerateDecelerateInterpolator(); case 1: return new AccelerateInterpolator(); case 2: return new AnticipateInterpolator(); case 3: return new AnticipateOvershootInterpolator(); case 4: return new BounceInterpolator(); case 5: return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f); case 6: return new DecelerateInterpolator(); case 7: return new LinearInterpolator(); case 8: return new OvershootInterpolator(); default: return new LinearInterpolator(); } } else { return new LinearInterpolator(); } }
Example #9
Source File: LauncherScroller.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
/** * Create a Scroller with the specified interpolator. If the interpolator is * null, the default (viscous) interpolator will be used. Specify whether or * not to support progressive "flywheel" behavior in flinging. */ public LauncherScroller(Context context, Interpolator interpolator, boolean flywheel) { mFinished = true; mInterpolator = interpolator; mPpi = context.getResources().getDisplayMetrics().density * 160.0f; mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction()); mFlywheel = flywheel; mPhysicalCoeff = computeDeceleration(0.84f); // look and feel tuning }
Example #10
Source File: KeyframeParser.java From lottie-android with Apache License 2.0 | 5 votes |
@Nullable private static WeakReference<Interpolator> getInterpolator(int hash) { // This must be synchronized because get and put isn't thread safe because // SparseArrayCompat has to create new sized arrays sometimes. synchronized (KeyframeParser.class) { return pathInterpolatorCache().get(hash); } }
Example #11
Source File: ImageMatrixTouchHandler.java From PinchToZoom with MIT License | 5 votes |
/** * <p>Performs a zoom animation from <code>scaleFrom</code> to <code>scaleTo</code> using the given <code>ScaleAnimatorHandler</code>.</p> * @param scaleFrom * @param scaleTo * @param duration * @param scaleAnimatorHandler * @param interpolator */ private void animateZoom(float scaleFrom, float scaleTo, long duration, ScaleAnimatorHandler scaleAnimatorHandler, Interpolator interpolator) { if(isAnimating()) { throw new IllegalStateException("An animation is currently running; Check isAnimating() first!"); } valueAnimator = ValueAnimator.ofFloat(scaleFrom, scaleTo); valueAnimator.setDuration(duration); valueAnimator.addUpdateListener(scaleAnimatorHandler); if(interpolator != null) valueAnimator.setInterpolator(interpolator); valueAnimator.start(); }
Example #12
Source File: CanvasTransformerBuilder.java From LiuAGeAndroid with MIT License | 5 votes |
public CanvasTransformer translate(final int openedX, final int closedX, final int openedY, final int closedY, final Interpolator interp) { initTransformer(); mTrans = new CanvasTransformer() { public void transformCanvas(Canvas canvas, float percentOpen) { mTrans.transformCanvas(canvas, percentOpen); float f = interp.getInterpolation(percentOpen); canvas.translate((openedX - closedX) * f + closedX, (openedY - closedY) * f + closedY); } }; return mTrans; }
Example #13
Source File: CircularProgressDrawable.java From ticdesign with Apache License 2.0 | 5 votes |
private CircularProgressDrawable(int padding, float initialAngle, float progressPercent, float secondaryProgressPercent, float maxSweepAngle, float minSweepAngle, int strokeSize, int[] strokeColors, int strokeSecondaryColor, boolean reverse, int rotateDuration, int transformDuration, int keepDuration, Interpolator transformInterpolator, int progressMode, int inAnimDuration, float inStepPercent, int[] inStepColors, int outAnimDuration, int alpha) { mPadding = padding; mInitialAngle = initialAngle; mAlpha = alpha; mProgressPercent = Math.min(1f, Math.max(0f, progressPercent)); // setProgress(progressPercent); setSecondaryProgress(secondaryProgressPercent); mMaxSweepAngle = maxSweepAngle; mMinSweepAngle = minSweepAngle; mStrokeSize = strokeSize; mStrokeColors = strokeColors; mStrokeSecondaryColor = strokeSecondaryColor; mReverse = reverse; mRotateDuration = rotateDuration; mTransformDuration = transformDuration; mKeepDuration = keepDuration; mTransformInterpolator = transformInterpolator; mProgressMode = progressMode; mInAnimationDuration = inAnimDuration; mInStepPercent = inStepPercent; mInColors = inStepColors; mOutAnimationDuration = outAnimDuration; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStrokeCap(Paint.Cap.BUTT); mPaint.setStrokeJoin(Paint.Join.ROUND); mRect = new RectF(); mState = createConstantState(null, null); }
Example #14
Source File: Animation.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
@NonNull public static Interpolator getInterpolator(int id) { switch (id) { case 0: return new LinearInterpolator(); case 1: return new AccelerateInterpolator(); case 2: return new DecelerateInterpolator(); case 3: return new AccelerateDecelerateInterpolator(); case 4: return new OvershootInterpolator(); case 5: return new AnticipateInterpolator(); case 6: return new AnticipateOvershootInterpolator(); case 7: return new BounceInterpolator(); case 8: return new FastOutLinearInInterpolator(); case 9: return new LinearInterpolator(); case 10: return new LinearOutSlowInInterpolator(); default: return new FastOutSlowInInterpolator(); } }
Example #15
Source File: AnimUtils.java From android-proguards with Apache License 2.0 | 5 votes |
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
Example #16
Source File: AbstractLayoutAnimation.java From react-native-GPay with MIT License | 5 votes |
private static Interpolator getInterpolator(InterpolatorType type, ReadableMap params) { Interpolator interpolator; if (type.equals(InterpolatorType.SPRING)) { interpolator = new SimpleSpringInterpolator(SimpleSpringInterpolator.getSpringDamping(params)); } else { interpolator = INTERPOLATOR.get(type); } if (interpolator == null) { throw new IllegalArgumentException("Missing interpolator for type : " + type); } return interpolator; }
Example #17
Source File: StaggeredAnimationGroupTest.java From StaggeredAnimationGroup with Apache License 2.0 | 5 votes |
@Test public void partialInterpolator_isModified_when_setPartialInterpolator_isCalled() { //given StaggeredAnimationGroup spiedGroup = prepareSpiedGroup(); Interpolator testInterpolator = new LinearOutSlowInInterpolator(); //when spiedGroup.setPartialInterpolator(testInterpolator); //then assertThat(spiedGroup.partialInterpolator).isEqualTo(testInterpolator); }
Example #18
Source File: AppTransition.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Prepares the specified animation with a standard duration, interpolator, etc. */ Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight, long duration, Interpolator interpolator) { if (duration > 0) { a.setDuration(duration); } a.setFillAfter(true); if (interpolator != null) { a.setInterpolator(interpolator); } a.initialize(appWidth, appHeight, appWidth, appHeight); return a; }
Example #19
Source File: LineMorphingDrawable.java From MDPreference with Apache License 2.0 | 5 votes |
private LineMorphingDrawable(State[] states, int curState, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, int animDuration, Interpolator interpolator, int strokeSize, int strokeColor, Paint.Cap strokeCap, Paint.Join strokeJoin, boolean clockwise, boolean isRtl){ mStates = states; mPaddingLeft = paddingLeft; mPaddingTop = paddingTop; mPaddingRight = paddingRight; mPaddingBottom = paddingBottom; mAnimDuration = animDuration; mInterpolator = interpolator; mStrokeSize = strokeSize; mStrokeColor = strokeColor; mStrokeCap = strokeCap; mStrokeJoin = strokeJoin; mClockwise = clockwise; mIsRtl = isRtl; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeCap(mStrokeCap); mPaint.setStrokeJoin(mStrokeJoin); mPaint.setColor(mStrokeColor); mPaint.setStrokeWidth(mStrokeSize); mDrawBound = new RectF(); mPath = new Path(); switchLineState(curState, false); }
Example #20
Source File: ViewAnimationUtil.java From SimpleProject with MIT License | 5 votes |
public static void alpha(View view, float fromAlpha, float toAlpha, int duration, Interpolator interpolator) { AlphaAnimation animation = new AlphaAnimation(fromAlpha, toAlpha); animation.setDuration(duration); animation.setFillAfter(true); animation.setInterpolator(interpolator); view.startAnimation(animation); }
Example #21
Source File: Morpho.java From morphos with Apache License 2.0 | 5 votes |
public Morpho build(AnimationType animationType, int duration, Interpolator interpolator) { if (animationType != null) { this.completeAnimationAnimationType = animationType; } this.completeAnimationDuration = duration; if (interpolator != null) { this.completeAnimationInterpolator = interpolator; } return this; }
Example #22
Source File: FloatingMenuAnimationHandler.java From floatingMenu with Apache License 2.0 | 4 votes |
public FloatingMenuAnimationHandler setOpeningInterpolator(Interpolator interpolator) { this.openingInterpolator = interpolator; return this; }
Example #23
Source File: MaterialMenuDrawable.java From HaiNaBaiChuan with Apache License 2.0 | 4 votes |
public void setInterpolator(Interpolator interpolator) { transformation.setInterpolator(interpolator); }
Example #24
Source File: EaseInExpo.java From Flubber with Apache License 2.0 | 4 votes |
@Override public Interpolator createInterpolatorFor(AnimationBody animationBody) { return PathInterpolatorCompat.create(0.95f, 0.05f, 0.795f, 0.035f); }
Example #25
Source File: Panning.java From PanningView with Apache License 2.0 | 4 votes |
public void setInterpolator(Interpolator interpolator) { this.interpolator = interpolator; }
Example #26
Source File: ViewPropertyAnimatorCompat.java From letv with Apache License 2.0 | 4 votes |
public Interpolator getInterpolator(ViewPropertyAnimatorCompat vpa, View view) { return null; }
Example #27
Source File: AnimatorInflater.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Creates a new animation whose parameters come from the specified context * and attributes set. * * @param res The resources * @param attrs The set of attributes holding the animation parameters * @param anim Null if this is a ValueAnimator, otherwise this is an * ObjectAnimator */ private static ValueAnimator loadAnimator(Resources res, Theme theme, AttributeSet attrs, ValueAnimator anim, float pathErrorScale) throws NotFoundException { TypedArray arrayAnimator = null; TypedArray arrayObjectAnimator = null; if (theme != null) { arrayAnimator = theme.obtainStyledAttributes(attrs, R.styleable.Animator, 0, 0); } else { arrayAnimator = res.obtainAttributes(attrs, R.styleable.Animator); } // If anim is not null, then it is an object animator. if (anim != null) { if (theme != null) { arrayObjectAnimator = theme.obtainStyledAttributes(attrs, R.styleable.PropertyAnimator, 0, 0); } else { arrayObjectAnimator = res.obtainAttributes(attrs, R.styleable.PropertyAnimator); } anim.appendChangingConfigurations(arrayObjectAnimator.getChangingConfigurations()); } if (anim == null) { anim = new ValueAnimator(); } anim.appendChangingConfigurations(arrayAnimator.getChangingConfigurations()); parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator, pathErrorScale); final int resID = arrayAnimator.getResourceId(R.styleable.Animator_interpolator, 0); if (resID > 0) { final Interpolator interpolator = AnimationUtils.loadInterpolator(res, theme, resID); if (interpolator instanceof BaseInterpolator) { anim.appendChangingConfigurations( ((BaseInterpolator) interpolator).getChangingConfiguration()); } anim.setInterpolator(interpolator); } arrayAnimator.recycle(); if (arrayObjectAnimator != null) { arrayObjectAnimator.recycle(); } return anim; }
Example #28
Source File: CustomScroller.java From SwipeSectorLayout with MIT License | 4 votes |
public CustomScroller(Context context, Interpolator interpolator, boolean flywheel) { super(context, interpolator, flywheel); }
Example #29
Source File: RadioRealButtonGroup.java From RadioRealButton with Apache License 2.0 | 4 votes |
public Interpolator getInterpolatorDrawablesEnter() { return interpolatorDrawablesEnter; }
Example #30
Source File: IndicatorLayout.java From AndroidBase with Apache License 2.0 | 4 votes |
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) { super(context); mArrowImageView = new ImageView(context); Drawable arrowD = getResources().getDrawable(com.ljz.base.widget.R.drawable.indicator_arrow); mArrowImageView.setImageDrawable(arrowD); final int padding = getResources().getDimensionPixelSize(com.ljz.base.widget.R.dimen.indicator_internal_padding); mArrowImageView.setPadding(padding, padding, padding, padding); addView(mArrowImageView); int inAnimResId, outAnimResId; switch (mode) { case PULL_FROM_END: inAnimResId = com.ljz.base.widget.R.anim.slide_in_from_bottom; outAnimResId = com.ljz.base.widget.R.anim.slide_out_to_bottom; setBackgroundResource(com.ljz.base.widget.R.drawable.indicator_bg_bottom); // Rotate Arrow so it's pointing the correct way mArrowImageView.setScaleType(ScaleType.MATRIX); Matrix matrix = new Matrix(); matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f); mArrowImageView.setImageMatrix(matrix); break; default: case PULL_FROM_START: inAnimResId = com.ljz.base.widget.R.anim.slide_in_from_top; outAnimResId = com.ljz.base.widget.R.anim.slide_out_to_top; setBackgroundResource(com.ljz.base.widget.R.drawable.indicator_bg_top); break; } mInAnim = AnimationUtils.loadAnimation(context, inAnimResId); mInAnim.setAnimationListener(this); mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId); mOutAnim.setAnimationListener(this); final Interpolator interpolator = new LinearInterpolator(); mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setInterpolator(interpolator); mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mRotateAnimation.setFillAfter(true); mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mResetRotateAnimation.setInterpolator(interpolator); mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mResetRotateAnimation.setFillAfter(true); }