Search in sources :

Example 36 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project AisenWeiBo by wangdan.

the class BizFragment method animScale.

public void animScale(final View likeView) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.5f, 1.0f, 1.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(200);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.start();
    likeView.startAnimation(scaleAnimation);
    likeView.postDelayed(new Runnable() {

        @Override
        public void run() {
            ScaleAnimation scaleAnimation = new ScaleAnimation(1.5f, 1.0f, 1.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            scaleAnimation.setDuration(200);
            scaleAnimation.setFillAfter(true);
            likeView.startAnimation(scaleAnimation);
        }
    }, 200);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 37 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project AisenWeiBo by wangdan.

the class MainFloatingActionButton method show.

/**
     * Shows the FAB and sets the FAB's translation.
     *
     * @param translationX translation X value
     * @param translationY translation Y value
     */
@Override
public void show(float translationX, float translationY) {
    // Set FAB's translation
    setTranslation(translationX, translationY);
    // Only use scale animation if FAB is hidden
    if (getVisibility() != View.VISIBLE) {
        // Pivots indicate where the animation begins from
        float pivotX = getPivotX() + translationX;
        float pivotY = getPivotY() + translationY;
        ScaleAnimation anim;
        // center of the FAB
        if (pivotX == 0 || pivotY == 0) {
            anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        } else {
            anim = new ScaleAnimation(0, 1, 0, 1, pivotX, pivotY);
        }
        // Animate FAB expanding
        anim.setDuration(FAB_ANIM_DURATION);
        anim.setInterpolator(getInterpolator());
        startAnimation(anim);
    }
    setVisibility(View.VISIBLE);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 38 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project AisenWeiBo by wangdan.

the class MainFloatingActionButton method hide.

/**
     * Hides the FAB.
     */
@Override
public void hide() {
    // Only use scale animation if FAB is visible
    if (getVisibility() == View.VISIBLE) {
        // Pivots indicate where the animation begins from
        float pivotX = getPivotX() + getTranslationX();
        float pivotY = getPivotY() + getTranslationY();
        // Animate FAB shrinking
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY);
        anim.setDuration(FAB_ANIM_DURATION);
        anim.setInterpolator(getInterpolator());
        startAnimation(anim);
    }
    setVisibility(View.INVISIBLE);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 39 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project smartmodule by carozhu.

the class AnimationController method scaleIn.

public void scaleIn(View view, long durationMillis, long delayMillis) {
    ScaleAnimation animation = new ScaleAnimation(0, 1, 0, 1, rela2, 0.5f, rela2, 0.5f);
    baseIn(view, animation, durationMillis, delayMillis);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 40 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project smartmodule by carozhu.

the class OptAnimationLoader method createAnimationFromXml.

private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {
    Animation anim = null;
    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();
    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("set")) {
            anim = new AnimationSet(c, attrs);
            createAnimationFromXml(c, parser, (AnimationSet) anim, attrs);
        } else if (name.equals("alpha")) {
            anim = new AlphaAnimation(c, attrs);
        } else if (name.equals("scale")) {
            anim = new ScaleAnimation(c, attrs);
        } else if (name.equals("rotate")) {
            anim = new RotateAnimation(c, attrs);
        } else if (name.equals("translate")) {
            anim = new TranslateAnimation(c, attrs);
        } else {
            try {
                anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
            } catch (Exception te) {
                throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
            }
        }
        if (parent != null) {
            parent.addAnimation(anim);
        }
    }
    return anim;
}
Also used : Context(android.content.Context) RotateAnimation(android.view.animation.RotateAnimation) AttributeSet(android.util.AttributeSet) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

ScaleAnimation (android.view.animation.ScaleAnimation)114 AnimationSet (android.view.animation.AnimationSet)60 AlphaAnimation (android.view.animation.AlphaAnimation)56 Animation (android.view.animation.Animation)50 TranslateAnimation (android.view.animation.TranslateAnimation)40 ClipRectAnimation (android.view.animation.ClipRectAnimation)28 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)28 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)26