Example usage for android.view.animation Animation RELATIVE_TO_SELF

List of usage examples for android.view.animation Animation RELATIVE_TO_SELF

Introduction

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

Prototype

int RELATIVE_TO_SELF

To view the source code for android.view.animation Animation RELATIVE_TO_SELF.

Click Source Link

Document

The specified dimension holds a float and should be multiplied by the height or width of the object being animated.

Usage

From source file:Main.java

public static RotateAnimation getRotateAnimation(float fromAngle, float toAngle, float pivotX, float pivotY,
        int intDuration, int intRepeatCount, boolean boolFillAfter) {
    RotateAnimation mAnmation = new RotateAnimation(fromAngle, toAngle, Animation.RELATIVE_TO_SELF, pivotX,
            Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);//from  w  w w .  j a  va 2 s .  c  o m
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    mAnmation.setInterpolator(new LinearInterpolator());
    return mAnmation;
}

From source file:Main.java

public static void showAnimation(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);//from  ww w . ja  va2 s  .c o  m
}

From source file:Main.java

public static void backAnimation(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);//from w  w  w.j a v a 2s .c  o  m
}

From source file:Main.java

public static void showAnimationFromTop(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f, Animation.RELATIVE_TO_SELF, 0f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);/*from w  ww.jav a 2s.  c  o  m*/
}

From source file:Main.java

public static void backAnimationFromBottom(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);/*from   w ww.  j a  va 2s  .  c  o  m*/
}

From source file:Main.java

public static void setRotateAnimation(View view, float fromAngle, float toAngle, float pivotX, float pivotY,
        int intDuration, int intRepeatCount, boolean boolFillAfter) {
    RotateAnimation mAnmation = new RotateAnimation(fromAngle, toAngle, Animation.RELATIVE_TO_SELF, pivotX,
            Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);//from w  ww  .j a va  2 s .  c  o m
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    mAnmation.setInterpolator(new LinearInterpolator());
    view.startAnimation(mAnmation);
}

From source file:Main.java

public static ScaleAnimation getScaleAnimation(float ScaleFromX, float ScaleToX, float ScaleFromY,
        float ScaleToY, float pivotX, float pivotY, int intDuration, int intRepeatCount,
        boolean boolFillAfter) {
    ScaleAnimation mAnmation = new ScaleAnimation(ScaleFromX, ScaleToX, ScaleFromY, ScaleToY,
            Animation.RELATIVE_TO_SELF, pivotX, Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);/*from  w w  w  . ja v  a  2 s .c  om*/
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }
    // translateAnimation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    return mAnmation;
}

From source file:Main.java

/**
 * Returns rotate animation that is set to refresh button to rotate refresh button.
 *  /*from  w ww .j av a2  s  .co m*/
 * @return RotateAnimation
 */
public static RotateAnimation getRefreshButtonAnimation() {
    rotateAnim = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    rotateAnim.setDuration(800);
    rotateAnim.setInterpolator(new LinearInterpolator());
    rotateAnim.setInterpolator(new LinearInterpolator());
    rotateAnim.setRepeatCount(RotateAnimation.INFINITE);

    return rotateAnim;
}

From source file:Main.java

public static AnimationSet FlipAnimation(int duration, int repeatCount) {
    AnimationSet flip = new AnimationSet(true);
    if (duration > 20) //Flip anim
    {/*from w w  w. j  av  a2  s . c  o  m*/
        Animation from_middle1_anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,
                .5f, Animation.RELATIVE_TO_SELF, .5f);
        from_middle1_anim.setDuration(duration);
        from_middle1_anim.setStartOffset(0);
        from_middle1_anim.setRepeatMode(Animation.REVERSE);
        from_middle1_anim.setRepeatCount(repeatCount);

        flip.addAnimation(from_middle1_anim);
    } else // no anim
    {
        Animation noAnim = new AlphaAnimation(1f, 1f);
        noAnim.setDuration(duration);
        flip.addAnimation(noAnim);
    }
    return flip;
}

From source file:Main.java

public static void setScaleAnimation(View view, float ScaleFromX, float ScaleToX, float ScaleFromY,
        float ScaleToY, float pivotX, float pivotY, int intDuration, int intRepeatCount,
        boolean boolFillAfter) {
    ScaleAnimation mAnmation = new ScaleAnimation(ScaleFromX, ScaleToX, ScaleFromY, ScaleToY,
            Animation.RELATIVE_TO_SELF, pivotX, Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);/*ww w .j a  v a2s . co m*/
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }
    // translateAnimation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    view.startAnimation(mAnmation);
}