use of android.view.animation.AlphaAnimation in project AndroidDevelop by 7449.
the class BadgeView method init.
private void init(Context context, View target, int tabIndex) {
this.context = context;
this.target = target;
this.targetTabIndex = tabIndex;
badgePosition = DEFAULT_POSITION;
badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP);
badgeMarginV = badgeMarginH;
badgeColor = DEFAULT_BADGE_COLOR;
setTypeface(Typeface.DEFAULT_BOLD);
int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP);
setPadding(paddingPixels, 0, paddingPixels, 0);
setTextColor(DEFAULT_TEXT_COLOR);
fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new DecelerateInterpolator());
fadeIn.setDuration(200);
fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setDuration(200);
isShown = false;
if (this.target != null) {
applyTo(this.target);
} else {
show();
}
}
use of android.view.animation.AlphaAnimation in project UltimateAndroid by cymcsg.
the class DraggableGridViewPager method animateDragged.
private void animateDragged() {
if (mLastDragged >= 0) {
final View v = getChildAt(mLastDragged);
final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
r.inset(-r.width() / 20, -r.height() / 20);
v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
v.layout(r.left, r.top, r.right, r.bottom);
AnimationSet animSet = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
scale.setDuration(ANIMATION_DURATION);
AlphaAnimation alpha = new AlphaAnimation(1, .5f);
alpha.setDuration(ANIMATION_DURATION);
animSet.addAnimation(scale);
animSet.addAnimation(alpha);
animSet.setFillEnabled(true);
animSet.setFillAfter(true);
v.clearAnimation();
v.startAnimation(animSet);
}
}
use of android.view.animation.AlphaAnimation in project UltimateAndroid by cymcsg.
the class ArcMenu method createItemDisapperAnimation.
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));
animationSet.setDuration(duration);
animationSet.setInterpolator(new DecelerateInterpolator());
animationSet.setFillAfter(true);
return animationSet;
}
use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.
the class ZoomControls method fade.
private void fade(int visibility, float startAlpha, float endAlpha) {
AlphaAnimation anim = new AlphaAnimation(startAlpha, endAlpha);
anim.setDuration(500);
startAnimation(anim);
setVisibility(visibility);
}
use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.
the class AppTransition method createClipRevealAnimationLocked.
private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame, Rect displayFrame) {
final Animation anim;
if (enter) {
final int appWidth = appFrame.width();
final int appHeight = appFrame.height();
// mTmpRect will contain an area around the launcher icon that was pressed. We will
// clip reveal from that area in the final area of the app.
getDefaultNextAppTransitionStartRect(mTmpRect);
float t = 0f;
if (appHeight > 0) {
t = (float) mTmpRect.top / displayFrame.height();
}
int translationY = mClipRevealTranslationY + (int) (displayFrame.height() / 7f * t);
int translationX = 0;
int translationYCorrection = translationY;
int centerX = mTmpRect.centerX();
int centerY = mTmpRect.centerY();
int halfWidth = mTmpRect.width() / 2;
int halfHeight = mTmpRect.height() / 2;
int clipStartX = centerX - halfWidth - appFrame.left;
int clipStartY = centerY - halfHeight - appFrame.top;
boolean cutOff = false;
// and extending the clip rect from that edge.
if (appFrame.top > centerY - halfHeight) {
translationY = (centerY - halfHeight) - appFrame.top;
translationYCorrection = 0;
clipStartY = 0;
cutOff = true;
}
if (appFrame.left > centerX - halfWidth) {
translationX = (centerX - halfWidth) - appFrame.left;
clipStartX = 0;
cutOff = true;
}
if (appFrame.right < centerX + halfWidth) {
translationX = (centerX + halfWidth) - appFrame.right;
clipStartX = appWidth - mTmpRect.width();
cutOff = true;
}
final long duration = calculateClipRevealTransitionDuration(cutOff, translationX, translationY, displayFrame);
// Clip third of the from size of launch icon, expand to full width/height
Animation clipAnimLR = new ClipRectLRAnimation(clipStartX, clipStartX + mTmpRect.width(), 0, appWidth);
clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
clipAnimLR.setDuration((long) (duration / 2.5f));
TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0);
translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR : mLinearOutSlowInInterpolator);
translate.setDuration(duration);
Animation clipAnimTB = new ClipRectTBAnimation(clipStartY, clipStartY + mTmpRect.height(), 0, appHeight, translationYCorrection, 0, mLinearOutSlowInInterpolator);
clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
clipAnimTB.setDuration(duration);
// Quick fade-in from icon to app window
final long alphaDuration = duration / 4;
AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
alpha.setDuration(alphaDuration);
alpha.setInterpolator(mLinearOutSlowInInterpolator);
AnimationSet set = new AnimationSet(false);
set.addAnimation(clipAnimLR);
set.addAnimation(clipAnimTB);
set.addAnimation(translate);
set.addAnimation(alpha);
set.setZAdjustment(Animation.ZORDER_TOP);
set.initialize(appWidth, appHeight, appWidth, appHeight);
anim = set;
mLastHadClipReveal = true;
mLastClipRevealTransitionDuration = duration;
// If the start rect was full inside the target rect (cutOff == false), we don't need
// to store the translation, because it's only used if cutOff == true.
mLastClipRevealMaxTranslation = cutOff ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0;
} else {
final long duration;
switch(transit) {
case TRANSIT_ACTIVITY_OPEN:
case TRANSIT_ACTIVITY_CLOSE:
duration = mConfigShortAnimTime;
break;
default:
duration = DEFAULT_APP_TRANSITION_DURATION;
break;
}
if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
// If we are on top of the wallpaper, we need an animation that
// correctly handles the wallpaper staying static behind all of
// the animated elements. To do this, will just have the existing
// element fade out.
anim = new AlphaAnimation(1, 0);
anim.setDetachWallpaper(true);
} else {
// For normal animations, the exiting element just holds in place.
anim = new AlphaAnimation(1, 1);
}
anim.setInterpolator(mDecelerateInterpolator);
anim.setDuration(duration);
anim.setFillAfter(true);
}
return anim;
}
Aggregations