Search in sources :

Example 51 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project Lazy by l123456789jy.

the class ViewAnimationUtils method goneViewByAlpha.

/**
     * 将给定视图渐渐隐去最后从界面中移除(view.setVisibility(View.GONE))
     *
     * @param view              被处理的视图
     * @param durationMillis    持续时间,毫秒
     * @param isBanClick        在执行动画的过程中是否禁止点击
     * @param animationListener 动画监听器
     */
public static void goneViewByAlpha(final View view, long durationMillis, final boolean isBanClick, final AnimationListener animationListener) {
    if (view.getVisibility() != View.GONE) {
        view.setVisibility(View.GONE);
        AlphaAnimation hiddenAlphaAnimation = AnimationUtils.getHiddenAlphaAnimation(durationMillis);
        hiddenAlphaAnimation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                if (isBanClick) {
                    view.setClickable(false);
                }
                if (animationListener != null) {
                    animationListener.onAnimationStart(animation);
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                if (animationListener != null) {
                    animationListener.onAnimationRepeat(animation);
                }
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (isBanClick) {
                    view.setClickable(true);
                }
                if (animationListener != null) {
                    animationListener.onAnimationEnd(animation);
                }
            }
        });
        view.startAnimation(hiddenAlphaAnimation);
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 52 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project SmartAndroidSource by jaychou2012.

the class DragGridView method animateDragged.

// EVENT HELPERS
protected void animateDragged() {
    View v = getChildAt(dragged);
    int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
    int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
    v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
    AnimationSet animSet = new AnimationSet(true);
    ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * 3 / 4);
    scale.setDuration(animT);
    AlphaAnimation alpha = new AlphaAnimation(1, .5f);
    alpha.setDuration(animT);
    animSet.addAnimation(scale);
    animSet.addAnimation(alpha);
    animSet.setFillEnabled(true);
    animSet.setFillAfter(true);
    v.clearAnimation();
    v.startAnimation(animSet);
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 53 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project SmartAndroidSource by jaychou2012.

the class DragGridViewPager 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);
    }
}
Also used : Rect(android.graphics.Rect) View(android.view.View) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 54 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project musicbrainz-android by jdamcd.

the class FadeImageView method fadeIn.

private void fadeIn() {
    AlphaAnimation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setDuration(DURATION);
    startAnimation(fadeIn);
}
Also used : AlphaAnimation(android.view.animation.AlphaAnimation)

Example 55 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project Signal-Android by WhisperSystems.

the class HidingLinearLayout method show.

public void show() {
    if (!isEnabled() || getVisibility() == VISIBLE)
        return;
    setVisibility(VISIBLE);
    AnimationSet animation = new AnimationSet(true);
    animation.addAnimation(new ScaleAnimation(0, 1, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
    animation.addAnimation(new AlphaAnimation(0, 1));
    animation.setDuration(100);
    animateWith(animation);
}
Also used : AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

AlphaAnimation (android.view.animation.AlphaAnimation)261 Animation (android.view.animation.Animation)111 TranslateAnimation (android.view.animation.TranslateAnimation)89 AnimationSet (android.view.animation.AnimationSet)78 ScaleAnimation (android.view.animation.ScaleAnimation)56 View (android.view.View)29 LinearInterpolator (android.view.animation.LinearInterpolator)26 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