Example usage for android.view.animation RotateAnimation RotateAnimation

List of usage examples for android.view.animation RotateAnimation RotateAnimation

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation RotateAnimation.

Prototype

public RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY) 

Source Link

Document

Constructor to use when building a RotateAnimation from code

Usage

From source file:Main.java

public static void btnRotate(View view) {
    RotateAnimation ra = new RotateAnimation(0, 360, 100, 100);
    ra.setDuration(1000);//from w w w  . j  a va2s  .  c o  m
    view.startAnimation(ra);
}

From source file:Main.java

public static void startAnimIn(RelativeLayout view) {
    RotateAnimation ra = new RotateAnimation(180, 360, view.getWidth() / 2, view.getHeight());
    ra.setDuration(500);/*ww w  .j  a v  a2s . c om*/
    ra.setFillAfter(true);
    view.startAnimation(ra);
}

From source file:Main.java

public static void viewShow(RelativeLayout view) {

    RotateAnimation animation = new RotateAnimation(180, 360, view.getWidth() / 2, view.getHeight());
    animation.setDuration(300);/*from  w  w w . ja  va2 s. c o m*/
    animation.setFillAfter(true);
    view.startAnimation(animation);

}

From source file:Main.java

public static void counterClockwiseRotation90ByCenter(View v) {
    float w = v.getWidth();
    float h = v.getHeight();
    RotateAnimation anim = new RotateAnimation(0, 90, w / 2, h / 2);
    anim.setDuration(10 * 1);/*from  ww  w  .  ja  v a2 s .  c o  m*/
    anim.setFillAfter(true);
    v.startAnimation(anim);
}

From source file:Main.java

public static void rotateInAnimation(RelativeLayout level, long i) {
    RotateAnimation animation = new RotateAnimation(180, 360, level.getWidth() / 2, level.getHeight());
    animation.setFillAfter(true);//  w w  w. j a  va 2  s.c  o  m
    animation.setDuration(500);
    animation.setStartOffset(i);
    level.startAnimation(animation);
}

From source file:Main.java

public static void rotateOutAnimation(RelativeLayout level, long i) {
    RotateAnimation animation = new RotateAnimation(0, 180, level.getWidth() / 2, level.getHeight());
    animation.setFillAfter(true);/*  w  ww  . j  a  va 2  s.c  o  m*/
    animation.setDuration(500);
    animation.setStartOffset(i);
    level.startAnimation(animation);
}

From source file:Main.java

public static void animateRotate(final View animated, float fromDegrees, float toDegrees,
        AnimationListener listener) {//from w ww  .  j  a v  a 2s  . c  o m
    if (animated == null) {
        return;
    }

    final RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, animated.getWidth() / 2,
            animated.getHeight() / 2);
    rotate.setDuration(ANIMATION_DURATION);
    rotate.setAnimationListener(listener);
    animated.startAnimation(rotate);
}

From source file:Main.java

public static void shakeAnimation(final View v) {
    float rotate = 0;
    int c = mCount++ % 5;
    if (c == 0) {
        rotate = DEGREE_0;/*w  w w. j  a va  2s . c  o  m*/
    } else if (c == 1) {
        rotate = DEGREE_1;
    } else if (c == 2) {
        rotate = DEGREE_2;
    } else if (c == 3) {
        rotate = DEGREE_3;
    } else {
        rotate = DEGREE_4;
    }
    final RotateAnimation mra = new RotateAnimation(rotate, -rotate, ICON_WIDTH * mDensity / 2,
            ICON_HEIGHT * mDensity / 2);
    final RotateAnimation mrb = new RotateAnimation(-rotate, rotate, ICON_WIDTH * mDensity / 2,
            ICON_HEIGHT * mDensity / 2);

    mra.setDuration(ANIMATION_DURATION);
    mrb.setDuration(ANIMATION_DURATION);

    mra.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (mNeedShake) {
                mra.reset();
                v.startAnimation(mrb);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {

        }

    });

    mrb.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (mNeedShake) {
                mrb.reset();
                v.startAnimation(mra);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {

        }

    });
    v.startAnimation(mra);
}

From source file:com.gigamole.millspinners.lib.CirclesWaveSpinner.java

private void init() {
    final LayoutParams tempArcViewLayoutParams = new LayoutParams(this.diameter, this.diameter);
    tempArcViewLayoutParams.gravity = Gravity.CENTER;

    for (int i = 0; i < this.circleViews.length; i++) {
        final CircleView tempCircleView = new CircleView(getContext());
        tempCircleView.setColor(this.colors[colorCounter++]);
        if (this.colorCounter == 3) {
            this.colorCounter = 0;
        }/*w  w  w .jav a2 s  .  co  m*/

        tempCircleView.setStartOffset((this.circleViews.length - 1 - i) * this.startOffset);
        tempCircleView.setStrokeWidth(this.strokeWidth);
        tempCircleView.setCircleMargin(this.marginCircleCounter += this.marginCircle);

        tempCircleView.setLayoutParams(tempArcViewLayoutParams);

        this.circleViews[i] = tempCircleView;
    }

    for (int i = this.circleViews.length - 1; i >= 0; i--) {
        this.addView(this.circleViews[i]);
        this.circleViews[i].init();
    }

    final Animation animation = new RotateAnimation(0, -45, this.radius, this.radius);
    animation.setFillAfter(true);
    startAnimation(animation);
}

From source file:com.actionbarsherlock.sample.styledactionbar.MainActivity.java

private void rotateLeftFrag() {
    if (leftFrag != null) {
        if (IS_HONEYCOMB) {
            ObjectAnimatorRotate.invoke(leftFrag.getView());
        } else {//from   w  w w . ja  v  a 2 s.  c om
            RotateAnimation rotate = new RotateAnimation(0, 180, leftFrag.getView().getWidth() / 2.0f,
                    leftFrag.getView().getHeight() / 2.0f);
            rotate.setDuration(500);
            leftFrag.getView().startAnimation(rotate);
        }
    }
}