Search in sources :

Example 71 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project android_frameworks_base by ParanoidAndroid.

the class AppTransition method createThumbnailAnimationLocked.

Animation createThumbnailAnimationLocked(int transit, boolean enter, boolean thumb, int appWidth, int appHeight) {
    Animation a;
    final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    if (thumb) {
        // filling the screen.
        if (mNextAppTransitionScaleUp) {
            float scaleW = appWidth / thumbWidth;
            float scaleH = appHeight / thumbHeight;
            Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
            scale.setInterpolator(mDecelerateInterpolator);
            Animation alpha = new AlphaAnimation(1, 0);
            alpha.setInterpolator(mThumbnailFadeoutInterpolator);
            // This AnimationSet uses the Interpolators assigned above.
            AnimationSet set = new AnimationSet(false);
            set.addAnimation(scale);
            set.addAnimation(alpha);
            a = set;
        } else {
            float scaleW = appWidth / thumbWidth;
            float scaleH = appHeight / thumbHeight;
            a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
        }
    } else if (enter) {
        // Entering app zooms out from the center of the thumbnail.
        if (mNextAppTransitionScaleUp) {
            float scaleW = thumbWidth / appWidth;
            float scaleH = thumbHeight / appHeight;
            a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        } else {
            // noop animation
            a = new AlphaAnimation(1, 1);
        }
    } else {
        // Exiting app
        if (mNextAppTransitionScaleUp) {
            if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
                // Fade out while bringing up selected activity. This keeps the
                // current activity from showing through a launching wallpaper
                // activity.
                a = new AlphaAnimation(1, 0);
            } else {
                // noop animation
                a = new AlphaAnimation(1, 1);
            }
        } else {
            float scaleW = thumbWidth / appWidth;
            float scaleH = thumbHeight / appHeight;
            Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
            Animation alpha = new AlphaAnimation(1, 0);
            AnimationSet set = new AnimationSet(true);
            set.addAnimation(scale);
            set.addAnimation(alpha);
            set.setZAdjustment(Animation.ZORDER_TOP);
            a = set;
        }
    }
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    final long duration;
    switch(transit) {
        case TRANSIT_ACTIVITY_OPEN:
        case TRANSIT_ACTIVITY_CLOSE:
            duration = mConfigShortAnimTime;
            break;
        default:
            duration = DEFAULT_APP_TRANSITION_DURATION;
            break;
    }
    a.setDuration(duration);
    a.setFillAfter(true);
    a.setInterpolator(mDecelerateInterpolator);
    a.initialize(appWidth, appHeight, appWidth, appHeight);
    return a;
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) Animation(android.view.animation.Animation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_activityCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation) WindowAnimation_taskToFrontEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation) WindowAnimation_wallpaperIntraOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) WindowAnimation_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 72 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project android_frameworks_base by ParanoidAndroid.

the class BitmapsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final BitmapsView view = new BitmapsView(this);
    final FrameLayout layout = new FrameLayout(this);
    layout.addView(view, new FrameLayout.LayoutParams(480, 800, Gravity.CENTER));
    setContentView(layout);
    ScaleAnimation a = new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    a.setDuration(2000);
    a.setRepeatCount(Animation.INFINITE);
    a.setRepeatMode(Animation.REVERSE);
    view.startAnimation(a);
}
Also used : FrameLayout(android.widget.FrameLayout) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 73 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project StickerCamera by Skykai521.

the class LabelView method wave.

public void wave() {
    AnimationSet as = new AnimationSet(true);
    ScaleAnimation sa = new ScaleAnimation(1f, 1.5f, 1f, 1.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(ANIMATIONEACHOFFSET * 3);
    // 设置循环
    sa.setRepeatCount(10);
    AlphaAnimation aniAlp = new AlphaAnimation(1, 0.1f);
    // 设置循环
    aniAlp.setRepeatCount(10);
    as.setDuration(ANIMATIONEACHOFFSET * 3);
    as.addAnimation(sa);
    as.addAnimation(aniAlp);
    labelIcon.startAnimation(as);
}
Also used : AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 74 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project cornerstone by Onskreen.

the class WindowManagerService method createThumbnailAnimationLocked.

private Animation createThumbnailAnimationLocked(int transit, boolean enter, boolean thumb, boolean delayed) {
    Animation a;
    final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    int duration;
    int delayDuration = delayed ? 270 : 0;
    switch(transit) {
        case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
        case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
            duration = mContext.getResources().getInteger(com.android.internal.R.integer.config_shortAnimTime);
            break;
        default:
            duration = delayed ? 250 : 300;
            break;
    }
    if (thumb) {
        // Animation for zooming thumbnail from its initial size to
        // filling the screen.
        float scaleW = mAppDisplayWidth / thumbWidth;
        float scaleH = mAppDisplayHeight / thumbHeight;
        Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
        AnimationSet set = new AnimationSet(true);
        Animation alpha = new AlphaAnimation(1, 0);
        scale.setDuration(duration);
        scale.setInterpolator(new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
        set.addAnimation(scale);
        alpha.setDuration(duration);
        set.addAnimation(alpha);
        set.setFillBefore(true);
        if (delayDuration > 0) {
            set.setStartOffset(delayDuration);
        }
        a = set;
    } else if (enter) {
        // Entering app zooms out from the center of the thumbnail.
        float scaleW = thumbWidth / mAppDisplayWidth;
        float scaleH = thumbHeight / mAppDisplayHeight;
        Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        scale.setDuration(duration);
        scale.setInterpolator(new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
        scale.setFillBefore(true);
        if (delayDuration > 0) {
            scale.setStartOffset(delayDuration);
        }
        a = scale;
    } else {
        if (delayed) {
            a = new AlphaAnimation(1, 0);
            a.setStartOffset(0);
            a.setDuration(delayDuration - 120);
            a.setBackgroundColor(0xFF000000);
        } else {
            a = createExitAnimationLocked(transit, duration);
        }
    }
    a.setFillAfter(true);
    final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_quad);
    a.setInterpolator(interpolator);
    a.initialize(mAppDisplayWidth, mAppDisplayHeight, mAppDisplayWidth, mAppDisplayHeight);
    return a;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 75 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project cornerstone by Onskreen.

the class WindowManagerService method createScaleUpAnimationLocked.

private Animation createScaleUpAnimationLocked(int transit, boolean enter) {
    Animation a;
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    int duration;
    switch(transit) {
        case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
        case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
            duration = mContext.getResources().getInteger(com.android.internal.R.integer.config_shortAnimTime);
            break;
        default:
            duration = 300;
            break;
    }
    if (enter) {
        // Entering app zooms out from the center of the initial rect.
        float scaleW = mNextAppTransitionStartWidth / (float) mAppDisplayWidth;
        float scaleH = mNextAppTransitionStartHeight / (float) mAppDisplayHeight;
        Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        scale.setDuration(duration);
        AnimationSet set = new AnimationSet(true);
        Animation alpha = new AlphaAnimation(0, 1);
        scale.setDuration(duration);
        set.addAnimation(scale);
        alpha.setDuration(duration);
        set.addAnimation(alpha);
        set.setDetachWallpaper(true);
        a = set;
    } else {
        a = createExitAnimationLocked(transit, duration);
    }
    a.setFillAfter(true);
    final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_cubic);
    a.setInterpolator(interpolator);
    a.initialize(mAppDisplayWidth, mAppDisplayHeight, mAppDisplayWidth, mAppDisplayHeight);
    return a;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) 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