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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations