Java Code Examples for android.view.animation.Animation#setInterpolator()
The following examples show how to use
android.view.animation.Animation#setInterpolator() .
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: ArcLayout.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) { AnimationSet animationSet = new AnimationSet(false); animationSet.setFillAfter(true); final long preDuration = duration / 2; Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setStartOffset(startOffset); rotateAnimation.setDuration(preDuration); rotateAnimation.setInterpolator(new LinearInterpolator()); rotateAnimation.setFillAfter(true); animationSet.addAnimation(rotateAnimation); Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720); translateAnimation.setStartOffset(startOffset + preDuration); translateAnimation.setDuration(duration - preDuration); translateAnimation.setInterpolator(interpolator); translateAnimation.setFillAfter(true); animationSet.addAnimation(translateAnimation); return animationSet; }
Example 2
Source File: RayLayout.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) { AnimationSet animationSet = new AnimationSet(false); animationSet.setFillAfter(true); final long preDuration = duration / 2; Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setStartOffset(startOffset); rotateAnimation.setDuration(preDuration); rotateAnimation.setInterpolator(new LinearInterpolator()); rotateAnimation.setFillAfter(true); animationSet.addAnimation(rotateAnimation); Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720); translateAnimation.setStartOffset(startOffset + preDuration); translateAnimation.setDuration(duration - preDuration); translateAnimation.setInterpolator(interpolator); translateAnimation.setFillAfter(true); animationSet.addAnimation(translateAnimation); return animationSet; }
Example 3
Source File: ScrollAwareFABBehavior.java From MarkdownEditors with Apache License 2.0 | 6 votes |
private void animateIn(FloatingActionButton button) { button.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button) .scaleX(1.0F) .scaleY(1.0F) .alpha(1.0F) .setInterpolator(INTERPOLATOR) .withLayer() .setListener(null) .start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_in); anim.setDuration(200L); anim.setInterpolator(INTERPOLATOR); button.startAnimation(anim); } }
Example 4
Source File: VoiceRecodingPanel.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private void hide(float x) { this.lastPositionX = x; float offset = getOffset(x); int widthAdjustment = getWidthAdjustment(); AnimationSet animation = new AnimationSet(false); Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment, Animation.ABSOLUTE, widthAdjustment, Animation.RELATIVE_TO_SELF, -.25f, Animation.RELATIVE_TO_SELF, -.25f); scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f)); translateAnimation.setInterpolator(new DecelerateInterpolator()); animation.addAnimation(scaleAnimation); animation.addAnimation(translateAnimation); animation.setDuration(ANIMATION_DURATION); animation.setFillBefore(true); animation.setFillAfter(false); animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f)); recordButtonFab.setVisibility(View.GONE); recordButtonFab.clearAnimation(); recordButtonFab.startAnimation(animation); }
Example 5
Source File: LabelView.java From AppCompat-Extension-Library with Apache License 2.0 | 5 votes |
private void showEclairMr1() { clearAnimation(); setVisibility(VISIBLE); Animation anim = createAnimationSet(0.0f, 1.0f, Math.round(mAnimationOffset), 0); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR); startAnimation(anim); }
Example 6
Source File: ClearEditText.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 5 votes |
/** * 晃动动画 * @param counts 1秒钟晃动多少下 * @return */ public static Animation shakeAnimation(int counts){ Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.setInterpolator(new CycleInterpolator(counts)); translateAnimation.setDuration(1000); return translateAnimation; }
Example 7
Source File: ViewExpanderCollapser.java From 1Rramp-Android with MIT License | 5 votes |
public static void expand(final View v) { v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); // Older versions of android (pre API 21) cancel animations for views with a height of 0. v.getLayoutParams().height = 1; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override public boolean willChangeBounds() { return true; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? ViewGroup.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); a.setInterpolator(new AccelerateInterpolator(3f)); v.startAnimation(a); }
Example 8
Source File: SearchAnimator.java From MeiZiNews with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static void fadeOutAnimation(final View view, int duration) { Animation anim = new AlphaAnimation(1.0f, 0.0f); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(duration); view.setAnimation(anim); view.setVisibility(View.GONE); }
Example 9
Source File: UiUtils.java From android-agera with Apache License 2.0 | 5 votes |
/** * Starts an animation that will jank if the UI thread is busy. * @param animView */ public static void startAnimation(View animView) { Animation tx = new TranslateAnimation(-350, 350, 0, 0); tx.setDuration(1000); tx.setRepeatCount(Animation.INFINITE); tx.setInterpolator(new AccelerateDecelerateInterpolator()); tx.setRepeatMode(Animation.REVERSE); animView.startAnimation(tx); }
Example 10
Source File: ArcMenu.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private static Animation createHintSwitchAnimation(final boolean expanded) { Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setStartOffset(0); animation.setDuration(100); animation.setInterpolator(new DecelerateInterpolator()); animation.setFillAfter(true); return animation; }
Example 11
Source File: HomeFragment.java From easyweather with MIT License | 5 votes |
@Override public void showNoData() { mSwipeLayout.setVisibility(View.GONE); refresh.setVisibility(View.VISIBLE); Animation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setRepeatCount(-1); animation.setInterpolator(new LinearInterpolator()); refresh.startAnimation(animation); mPresenter.doRefreshInNoData(); }
Example 12
Source File: RentalsSunDrawable.java From android-Ultra-Pull-To-Refresh-With-Load-More-master with MIT License | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 13
Source File: ClearEditText.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
/** * 晃动动画 * * @param counts 1秒钟晃动多少下 * @return */ public static Animation shakeAnimation(int counts) { Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.setInterpolator(new CycleInterpolator(counts)); translateAnimation.setDuration(1000); return translateAnimation; }
Example 14
Source File: AnimationFactory.java From PullToRefresh with MIT License | 5 votes |
private void configureAnimation(Animation animation, Interpolator interpolator, int duration, int startOffset, int repeatMode, int repeatCount) { animation.setInterpolator(interpolator); animation.setDuration(duration); animation.setStartOffset(startOffset); animation.setRepeatMode(repeatMode); animation.setRepeatCount(repeatCount); }
Example 15
Source File: RentalsSunDrawable.java From android-Ultra-Pull-To-Refresh with MIT License | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 16
Source File: ViewFlipperTestActivity.java From coursera-android with MIT License | 5 votes |
private Animation outToLeftAnimation() { Animation outToLeft = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outToLeft.setDuration(500); outToLeft.setInterpolator(new LinearInterpolator()); return outToLeft; }
Example 17
Source File: ClearEditText.java From Android_UE with Apache License 2.0 | 5 votes |
/** * 晃动动画 * * @param counts 1秒钟晃动多少下 * @return */ public static Animation shakeAnimation(int counts) { Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.setInterpolator(new CycleInterpolator(counts)); translateAnimation.setDuration(800); return translateAnimation; }
Example 18
Source File: Animations.java From WaniKani-for-Android with GNU General Public License v3.0 | 4 votes |
public static Animation FadeOut() { Animation anim = new AlphaAnimation(1 ,0); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); return anim; }
Example 19
Source File: FigureSpinner.java From MillSpinners with Apache License 2.0 | 4 votes |
private void init() { final LayoutParams tempFigureLayoutParams = new LayoutParams(this.diameter, this.diameter); tempFigureLayoutParams.gravity = Gravity.CENTER; for (int i = 0; i < this.figureViews.length; i++) { final FigureView figureView = new FigureView(getContext()); figureView.setColor(this.colors[i]); figureView.setFigureMargin(this.marginFigureCounter += this.marginFigure); if (this.isRounded) { figureView.setRounded(); } Animation tempAnimation = new RotateAnimation(0, this.angle, this.radius, this.radius); tempAnimation.setStartOffset(this.startOffsetCounter); tempAnimation.setDuration(this.speed - this.startOffsetCounter); this.startOffsetCounter -= this.startOffset; figureView.setDrawingCacheEnabled(true); tempAnimation.setFillEnabled(true); tempAnimation.setFillBefore(true); tempAnimation.setFillAfter(true); tempAnimation.setRepeatMode(Animation.RESTART); tempAnimation.setRepeatCount(Animation.INFINITE); tempAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); figureView.startAnimation(tempAnimation); figureView.setLayoutParams(tempFigureLayoutParams); this.figureViews[i] = figureView; this.addView(figureView); } if (this.isRotated) { final Animation spinningAnimation = new RotateAnimation(0, 360, this.radius, this.radius); spinningAnimation.setDuration(this.speed * 5); spinningAnimation.setInterpolator(new LinearInterpolator()); spinningAnimation.setRepeatMode(Animation.RESTART); spinningAnimation.setRepeatCount(Animation.INFINITE); startAnimation(spinningAnimation); } }
Example 20
Source File: ViewUtil.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private static Animation getAlphaAnimation(float from, float to, int duration) { final Animation anim = new AlphaAnimation(from, to); anim.setInterpolator(new FastOutSlowInInterpolator()); anim.setDuration(duration); return anim; }