List of usage examples for android.view.animation AlphaAnimation AlphaAnimation
public AlphaAnimation(float fromAlpha, float toAlpha)
From source file:Main.java
public static void switchViewsVisibilityByFade(final View oldView, final View newView) { final Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setDuration(700);// www . jav a 2s .c om Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setDuration(700); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { oldView.setVisibility(View.GONE); newView.setVisibility(View.VISIBLE); newView.startAnimation(fadeIn); } }); oldView.startAnimation(fadeOut); }
From source file:Main.java
protected static void show(final View view) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setStartOffset(500);//from w ww .jav a 2s. c o m fadeIn.setDuration(500); Animation collapse = new ScaleAnimation(1, 1, 0, 1); collapse.setDuration(500); AnimationSet animation = new AnimationSet(false); animation.setInterpolator(new AccelerateInterpolator()); animation.addAnimation(collapse); animation.addAnimation(fadeIn); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); view.startAnimation(animation); }
From source file:Main.java
public static void fadeOut(final View view, AnimationListener animationListener, int duration) { view.setVisibility(View.VISIBLE); Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f); alphaAnimation.setDuration(duration); alphaAnimation.setAnimationListener(animationListener); view.startAnimation(alphaAnimation); }
From source file:Main.java
public static void blink(View view, int durationMs, int repeatCount) { Animation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(durationMs); //You can manage the time of the blink with this parameter anim.setStartOffset(0);//from www. jav a2 s . c o m anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(repeatCount); view.startAnimation(anim); }
From source file:Main.java
public static void postAnimation(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;//from w w w. ja v a 2s. com } childLayout.setVisibility(View.INVISIBLE); childLayout.postDelayed(new Runnable() { @Override public void run() { childLayout.setVisibility(View.VISIBLE); AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(duration); animationSet.setInterpolator(new OvershootInterpolator(0.8f)); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
From source file:Main.java
public static void postAnimationBottom(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;// ww w . j a v a 2s . c om } childLayout.setVisibility(View.INVISIBLE); childLayout.postDelayed(new Runnable() { @Override public void run() { childLayout.setVisibility(View.VISIBLE); AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(duration); animationSet.setInterpolator(new AccelerateDecelerateInterpolator()); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
From source file:Main.java
/** * Fade in a view with the default time//from w w w .ja v a2 s . co m * @param view The {@link View} to use */ public static void fadeOut(View view) { if (view.getVisibility() != View.VISIBLE) return; // Since the button is still clickable before fade-out animation // ends, we disable the button first to block click. view.setEnabled(false); Animation animation = new AlphaAnimation(1F, 0F); animation.setDuration(400); view.startAnimation(animation); view.setVisibility(View.GONE); }
From source file:Main.java
public static void fadeOut(final View view) { view.setVisibility(View.VISIBLE); Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f); alphaAnimation.setDuration(FADE_DURATION); alphaAnimation.setAnimationListener(new AnimationListener() { @Override/*from w ww . j a v a 2 s . c o m*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } }); view.startAnimation(alphaAnimation); }
From source file:Main.java
/** * Fade in a view from startAlpha to endAlpha during duration milliseconds * @param view The {@link View} to use// w w w . ja v a2s .c o m * @param startAlpha * @param endAlpha * @param duration */ public static void fadeIn(View view, float startAlpha, float endAlpha, long duration) { if (view.getVisibility() == View.VISIBLE) { return; } view.setVisibility(View.VISIBLE); Animation animation = new AlphaAnimation(startAlpha, endAlpha); animation.setDuration(duration); view.startAnimation(animation); }
From source file:com.dm.material.dashboard.candybar.utils.Animator.java
public static void startAlphaAnimation(@Nullable View view, long duration, int visibility) { if (view == null) return;/*from ww w . java 2s. c om*/ AlphaAnimation alphaAnimation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f) : new AlphaAnimation(1f, 0f); alphaAnimation.setDuration(duration); alphaAnimation.setFillAfter(true); view.startAnimation(alphaAnimation); }