List of usage examples for android.view.animation CycleInterpolator CycleInterpolator
public CycleInterpolator(float cycles)
From source file:Main.java
public static CycleInterpolator getCycleInterpolator(float cycles) { return new CycleInterpolator(cycles); }
From source file:Main.java
public static void makeSnake(View v) { ObjectAnimator snake = ObjectAnimator.ofFloat(v, "translationX", 0, 10).setDuration(300); snake.setInterpolator(new CycleInterpolator(2)); snake.start();//from w w w . j a va 2 s. com }
From source file:Main.java
public static Animation shakeUpAndDownAnimation(int counts) { Animation translateAnimation = new TranslateAnimation(0, 0, 0, 10); translateAnimation.setInterpolator(new CycleInterpolator(counts)); translateAnimation.setDuration(500); return translateAnimation; }
From source file:Main.java
public static void shakeAnim(View view) { Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.setInterpolator(new CycleInterpolator(4)); translateAnimation.setDuration(400); view.startAnimation(translateAnimation); }
From source file:Main.java
public static Animation shakeAnimation(int counts) { Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.setInterpolator(new CycleInterpolator(counts)); translateAnimation.setDuration(1000); return translateAnimation; }
From source file:Main.java
/** * shake x//from w ww.java2s .c om * * @param v * @param offset * @param duration * @param times */ public static void shakeX(View v, float offset, long duration, float times) { ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.TRANSLATION_X, 0, offset); animator.setDuration(duration); animator.setInterpolator(new CycleInterpolator(times)); animator.start(); }
From source file:Main.java
/** * shake y//from w w w . j a v a 2 s .c o m * * @param v * @param offset * @param duration * @param times */ public static void shakeY(View v, float offset, long duration, float times) { ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.TRANSLATION_Y, 0, offset); animator.setDuration(duration); animator.setInterpolator(new CycleInterpolator(times)); animator.start(); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java
public static void doAction(View view, int duration, float scaleX, float scaleY) { try {/*from w ww .ja v a2 s.c o m*/ if (view.getScaleX() == 1) { ViewCompat.animate(view).setDuration(duration).scaleX(scaleX).scaleY(scaleY) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View v) { } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } } catch (Exception e) { Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction"); } }
From source file:Main.java
/** * translate the view./*from w w w. j a v a 2 s . c o m*/ * * @param view view to be translated * @param fromXDelta Change in X coordinate to apply at the start of the * animation * @param toXDelta Change in X coordinate to apply at the end of the * animation * @param fromYDelta Change in Y coordinate to apply at the start of the * animation * @param toYDelta Change in Y coordinate to apply at the end of the * animation * @param cycles Repeats the animation for a specified number of cycles {@link CycleInterpolator}. * @param durationMillis Duration in milliseconds * @param isBanClick whether view can click in animation */ public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, float cycles, long durationMillis, final boolean isBanClick) { TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta); translateAnimation.setDuration(durationMillis); if (cycles > 0.0) { translateAnimation.setInterpolator(new CycleInterpolator(cycles)); } translateAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isBanClick) { view.setClickable(false); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isBanClick) { view.setClickable(true); } } }); view.startAnimation(translateAnimation); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java
public static void doAction(ViewGroup view, int duration, float scaleX, float scaleY) { try {/* w ww . ja v a 2 s . c o m*/ if (view.getScaleX() == 1) { ViewCompat.animate(view).setDuration(duration).scaleX(scaleX).scaleY(scaleY) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View v) { } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); for (int index = 0; index < ((ViewGroup) view).getChildCount(); ++index) { View nextChild = ((ViewGroup) view).getChildAt(index); ViewCompat.animate(nextChild).setDuration(duration).scaleX(scaleX).scaleY(scaleY) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View v) { } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } } } catch (Exception e) { Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction"); } }