List of usage examples for android.view.animation AlphaAnimation AlphaAnimation
public AlphaAnimation(float fromAlpha, float toAlpha)
From source file:Main.java
public static AnimationSet RotateAndFadeInAnimation() { AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f); fade_in.setDuration(400);/*w w w . j av a2s .c om*/ fade_in.setStartOffset(0); fade_in.setFillAfter(true); ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); expand.setDuration(500); expand.setStartOffset(0); expand.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); // rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_in); Reload.addAnimation(expand); Reload.addAnimation(rotate); Reload.setInterpolator(new DecelerateInterpolator(1.3f)); return Reload; }
From source file:Main.java
public static void SetFlickerAnimation(final TextView v, final String info, final String temp) { v.setText(info);/*from ww w .ja v a 2 s . c o m*/ AlphaAnimation anim = new AlphaAnimation(0, 1); anim.setDuration(4000); anim.setRepeatCount(Animation.INFINITE); // anim1.setRepeatMode(Animation.REVERSE); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub num++; if (num == 10) { num = 0; } if (num % 2 == 0) { v.setText(info); } else { v.setText(temp); } } @Override public void onAnimationEnd(Animation arg0) { // TODO Auto-generated method stub } }); v.startAnimation(anim); }
From source file:Main.java
public static GridLayoutAnimationController getLayoutAnimation() { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(40);/*from www . j a v a 2 s. c o m*/ set.addAnimation(animation); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(75); set.addAnimation(animation); GridLayoutAnimationController controller = new GridLayoutAnimationController(set); return controller; }
From source file:Main.java
public static AnimationSet RotateAndFadeOutAnimation() { AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f); fade_out.setDuration(500);/*from ww w .ja v a 2 s. c o m*/ fade_out.setStartOffset(0); fade_out.setFillAfter(true); ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); shrink.setDuration(400); shrink.setStartOffset(0); shrink.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_out); Reload.addAnimation(shrink); Reload.addAnimation(rotate); Reload.setInterpolator(new AccelerateInterpolator(1.1f)); return Reload; }
From source file:Main.java
public static void SetMenuAnimation(final ImageView v, final int bg1, final int bg2) { v.setImageResource(bg1);/*from w w w. j av a2s. c om*/ AlphaAnimation anim = new AlphaAnimation(0.8f, 1); anim.setDuration(1000); anim.setRepeatCount(Animation.INFINITE); // anim1.setRepeatMode(Animation.REVERSE); anim.setInterpolator(new AccelerateInterpolator()); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub num++; if (num == 10) { num = 0; } if (num % 2 == 0) { v.setImageResource(bg1); } else { v.setImageResource(bg2); } } @Override public void onAnimationEnd(Animation arg0) { // TODO Auto-generated method stub } }); v.startAnimation(anim); }
From source file:Main.java
public static void makeViewGroupAnimation(ViewGroup viewGroup) { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(50);//from w ww . ja va 2s . c o m set.addAnimation(animation); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(150); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); viewGroup.setLayoutAnimation(controller); }
From source file:Main.java
public static List<Animation> initAnimation(int AnimationType, float fromAlpha, float toAlpha, float fromDegress, float toDegress, float pinX, float pinY) { List<Animation> animations = new ArrayList<>(); AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha); alphaAnimation.setDuration(300);//from ww w. j a v a 2s . c o m AlphaAnimation exit_alphaAnimation = new AlphaAnimation(toAlpha, fromAlpha); exit_alphaAnimation.setDuration(300); OvershootInterpolator overshootInterpolator = new OvershootInterpolator(3.5f); RotateAnimation rotateAnimation = new RotateAnimation(fromDegress, toDegress, AnimationType, pinX, AnimationType, pinY); rotateAnimation.setDuration(300); rotateAnimation.setInterpolator(overshootInterpolator); rotateAnimation.setFillAfter(true); RotateAnimation exit_rotateAnimation = new RotateAnimation(toDegress, fromAlpha, AnimationType, pinX, AnimationType, pinY); exit_rotateAnimation.setDuration(300); exit_rotateAnimation.setInterpolator(overshootInterpolator); exit_rotateAnimation.setFillAfter(true); animations.add(alphaAnimation); animations.add(exit_alphaAnimation); animations.add(rotateAnimation); animations.add(exit_rotateAnimation); return animations; }
From source file:Main.java
/** * Animate a view to fade in./* w w w . j av a 2 s . co m*/ * * @param view The view to be animated. * @param duration Duration that the animation should run, in milliseconds; specify -1 to use the default. * @param interpolator The interpolator which defines the acceleration curve; can be null to use default. */ public static void startFadeIn(View view, long duration, Interpolator interpolator) { AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f); if (duration > 0) { alphaAnimation.setDuration(duration); } if (interpolator != null) { alphaAnimation.setInterpolator(interpolator); } view.startAnimation(alphaAnimation); }
From source file:Main.java
public static void animationAlpha(View paramView, long paramLong, float paramFloat1, float paramFloat2, Animation.AnimationListener paramAnimationListener) { AlphaAnimation localAlphaAnimation = new AlphaAnimation(paramFloat1, paramFloat2); localAlphaAnimation.setAnimationListener(paramAnimationListener); animation(paramView, localAlphaAnimation, 500L, paramLong); }
From source file:Main.java
/** * This method will cause a view to fade out after which it fires a callback where operations can be performed then it will fade back in * @param view the view to fade/* w w w.j a v a 2 s.c om*/ * @param callback the callback to execute after the view has faded out */ public static void fadeOutIn(final View view, final Handler.Callback callback) { final Animation in = new AlphaAnimation(0.0f, 1.0f); in.setDuration(ANIMATION_SPEED); final Animation out = new AlphaAnimation(1.0f, 0.0f); out.setDuration(ANIMATION_SPEED); out.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { callback.handleMessage(null); view.startAnimation(in); } @Override public void onAnimationRepeat(Animation animation) { } }); view.startAnimation(out); }