Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setInterpolator(new DecelerateInterpolator()); //add this fadeIn.setDuration(1000); Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); //and this fadeOut.setStartOffset(1000); fadeOut.setDuration(1000); AnimationSet animation = new AnimationSet(false); //change to false animation.addAnimation(fadeIn); animation.addAnimation(fadeOut); this.setAnimation(animation);
@Override public Animation build(Context context) { return AnimationUtils.loadAnimation(context, animationId); } }
LottieInterpolatedValue(T startValue, T endValue) { this(startValue, endValue, new LinearInterpolator()); }
private Animation inFromRightAnimation() { Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); inFromRight.setDuration(500); inFromRight.setInterpolator(new LinearInterpolator()); return inFromRight; }
/** * Animates {@link ImageView} with "fade-in" effect * * @param imageView {@link ImageView} which display image in * @param durationMillis The length of the animation in milliseconds */ public static void animate(View imageView, int durationMillis) { if (imageView != null) { AlphaAnimation fadeImage = new AlphaAnimation(0, 1); fadeImage.setDuration(durationMillis); fadeImage.setInterpolator(new DecelerateInterpolator()); imageView.startAnimation(fadeImage); } } }
final Animation in = new AlphaAnimation(0.0f, 1.0f); in.setDuration(3000); final Animation out = new AlphaAnimation(1.0f, 0.0f); out.setDuration(3000); AnimationSet as = new AnimationSet(true); as.addAnimation(out); in.setStartOffset(3000); as.addAnimation(in);
private void setupAnimations() { fadeInAnimation = new AlphaAnimation(0.0f, 1.0f); fadeInAnimation.setDuration(300); fadeInAnimation.setInterpolator(new AccelerateInterpolator()); fadeInAnimation.setAnimationListener(this); fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); fadeOutAnimation.setDuration(300); fadeOutAnimation.setInterpolator(new AccelerateInterpolator()); fadeOutAnimation.setAnimationListener(this); }
TextView myText = (TextView) findViewById(R.id.myText ); Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(50); //You can manage the blinking time with this parameter anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); myText.startAnimation(anim);
public SmartIndicationInterpolator(float factor) { leftEdgeInterpolator = new AccelerateInterpolator(factor); rightEdgeInterpolator = new DecelerateInterpolator(factor); }
RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f); anim.setInterpolator(new LinearInterpolator()); anim.setRepeatCount(Animation.INFINITE); anim.setDuration(700); // Start animating the image final ImageView splash = (ImageView) findViewById(R.id.splash); splash.startAnimation(anim); // Later.. stop the animation splash.setAnimation(null);
public void onAnimationEnd(Animation animation) { animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 0.0f); animation.setDuration(1); mPlayer0Panel.startAnimation(animation); }
final int newLeftMargin = <some value>; Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { LayoutParams params = yourView.getLayoutParams(); params.leftMargin = (int)(newLeftMargin * interpolatedTime); yourView.setLayoutParams(params); } }; a.setDuration(500); // in ms yourView.startAnimation(a);
animation1 = new AlphaAnimation(0.0f, 1.0f); animation1.setDuration(1000); animation1.setStartOffset(5000); animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(1000); animation2.setStartOffset(5000); textView.startAnimation(animation1);
public static Interpolator getFastOutLinearInInterpolator(Context context) { if (fastOutLinearIn == null) { fastOutLinearIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_linear_in); } return fastOutLinearIn; }
/** * Gets the current position of the animation in time, which is equal to the current * time minus the time that the animation started. An animation that is not yet started will * return a value of zero. * * @return The current position in time of the animation. */ public long getCurrentPlayTime() { if (!mInitialized || mPlayingState == STOPPED) { return 0; } return AnimationUtils.currentAnimationTimeMillis() - mStartTime; }
public void start(float fromAlpha, float toAlpha) { mFromAlpha = fromAlpha; mToAlpha = toAlpha; super.start(); }
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; } }
public static Interpolator getLinearInterpolator() { if (linear == null) { linear = new LinearInterpolator(); } return linear; }
public static Interpolator getLinearOutSlowInInterpolator(Context context) { if (linearOutSlowIn == null) { linearOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); } return linearOutSlowIn; }
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }