Refine search
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; }
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);
private void animOut(final View v){ Animation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
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; } }
private void fadeOutAndHideImage(final ImageView img) { Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(1000); fadeOut.setAnimationListener(new AnimationListener() { public void onAnimationEnd(Animation animation) { img.setVisibility(View.GONE); } public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) {} }); img.startAnimation(fadeOut); }
private void animIn(final View v){ Animation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(anim); }
@Override public int onFinish(@NonNull RefreshLayout layout, boolean success) { final View thisView = this; thisView.clearAnimation(); if (success) { thisView.startAnimation(new Animation() {{ super.setDuration(100); super.setInterpolator(new AccelerateInterpolator()); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (interpolatedTime == 1) { isRefreshing = false; } mFinishTransformation = interpolatedTime; thisView.invalidate(); } }); return 200; } else { isRefreshing = false; return 0; } }
public void onCreate(Bundle savedInstanceState) { final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in final Button btn = (Button) findViewById(R.id.your_btn); btn.startAnimation(animation); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View view) { view.clearAnimation(); } }); }
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);
@Override public int onFinish(@NonNull RefreshLayout layout, boolean success) { mIsInLoading = false; mAniController.stop(); if (success && mEnableFadeAnimation) { final View thisView = this; thisView.startAnimation(new Animation() {{ super.setDuration(250); super.setInterpolator(new AccelerateInterpolator()); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final View thisView = StoreHouseHeader.this; mProgress = (1 - interpolatedTime); thisView.invalidate(); if (interpolatedTime == 1) { for (int i = 0; i < mItemList.size(); i++) { mItemList.get(i).resetPosition(mHorizontalRandomness); } } } }); return 250; } else { for (int i = 0; i < mItemList.size(); i++) { mItemList.get(i).resetPosition(mHorizontalRandomness); } } return 0; }
Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setInterpolator(new DecelerateInterpolator()); // add this fadeIn.setDuration(fadeInDuration); Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); // and this fadeOut.setStartOffset(fadeInDuration + timeBetween); fadeOut.setDuration(fadeOutDuration);
private void animOut(final View v, final boolean setGone, final boolean immediately){ if(!isShowing() || v.getVisibility() != View.VISIBLE || immediately) { v.setVisibility(setGone ? View.GONE : View.INVISIBLE); return; } Animation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { v.setVisibility(setGone ? View.GONE : View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); inFromRight.setDuration(500); inFromRight.setInterpolator(new AccelerateInterpolator()); return inFromRight; Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoLeft.setDuration(500); outtoLeft.setInterpolator(new AccelerateInterpolator()); return outtoLeft; Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); inFromLeft.setDuration(500); inFromLeft.setInterpolator(new AccelerateInterpolator()); return inFromLeft; Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoRight.setDuration(500); outtoRight.setInterpolator(new AccelerateInterpolator()); return outtoRight;
anim = new AlphaAnimation(0, 1); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(FADE_DUR); }else{
private void animIn(final View v, boolean immediately){ if(v.getVisibility() == View.VISIBLE) return; if(!isShowing() || immediately) { v.setVisibility(View.VISIBLE); return; } Animation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) {} @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
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); }
Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setInterpolator(new DecelerateInterpolator()); //add this fadeIn.setDuration(1500); //time in milliseconds Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); //and this fadeOut.setStartOffset(1000); fadeOut.setDuration(1500); //time in milliseconds AnimationSet animation = new AnimationSet(false); //change to false animation.addAnimation(fadeIn); animation.addAnimation(fadeOut); this.setAnimation(animation);
public static Animation fade(int type, int duration, int offset) { float startValue = type; Animation animation = new AlphaAnimation(startValue, 1.0f - startValue); animation.setDuration(duration); if (type == FADE_IN) { animation.setZAdjustment(Animation.ZORDER_TOP); } animation.setStartOffset(offset); return animation; } }
private void initAnimation() { mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mRotateAnimation.setDuration(ANIMATION_DURATION); mRotateAnimation.setFillAfter(true); mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mResetRotateAnimation.setDuration(ANIMATION_DURATION); mResetRotateAnimation.setFillAfter(true); }
Animation animation = new AlphaAnimation(1, 0); // Change alpha // from fully // visible to // invisible animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter // animation // rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation // infinitely animation.setRepeatMode(Animation.REVERSE); // Reverse animation at // the // end so the layout will // fade back in relativeLayout.startAnimation(animation);