Example usage for android.view.animation AlphaAnimation setInterpolator

List of usage examples for android.view.animation AlphaAnimation setInterpolator

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation setInterpolator.

Prototype

public void setInterpolator(Interpolator i) 

Source Link

Document

Sets the acceleration curve for this animation.

Usage

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation./*  ww  w  . j a  v a  2s .c  o  m*/
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * Second part of the click animation./*ww  w. j a  v a 2 s .  co m*/
 *
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimUp(View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = root.findViewById(R.id.rect_view_id);
    if (rectView != null) {
        AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f);
        rectAnim.setFillAfter(true);
        rectAnim.setInterpolator(new DecelerateInterpolator());
        rectAnim.setDuration(150);
        rectAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        ViewGroup parent = (ViewGroup) rectView.getParent();
                        rectView.setVisibility(View.GONE);
                        if (parent != null)
                            parent.removeView(rectView);
                    }
                });
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        rectView.clearAnimation();
        rectView.startAnimation(rectAnim);
    }
}

From source file:com.numix.calculator.EventListener.java

private void deleteAnimation(View view) {
    final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor);
    final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout);
    final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView()
            .findViewById(R.id.display);

    int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight());

    // create the animator for this view (the start radius is zero)
    Animator colorAnim;// w w  w . j  ava2s  . co  m
    colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(),
            (int) displayView.getBottom(), 0, finalRadius);
    final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
    final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f);
    fadeAnim.setDuration(250);
    fadeAnim.setInterpolator(new AccelerateInterpolator());
    fadeAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            colorLayout.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    fadeDisplay.setDuration(250);
    fadeDisplay.setInterpolator(new AccelerateInterpolator());
    fadeDisplay.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mHandler.onClear();
            displayView.setAlpha(1.0f);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    colorAnim.setInterpolator(new AccelerateInterpolator());
    colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(android.animation.Animator animation) {
            calculatorDisplay.startAnimation(fadeDisplay);
        }

        @Override
        public void onAnimationRepeat(android.animation.Animator animation) {
        }

        @Override
        public void onAnimationEnd(android.animation.Animator animation) {
            colorLayout.startAnimation(fadeAnim);
        }

        @Override
        public void onAnimationCancel(android.animation.Animator animation) {
        }
    });

    colorLayout.setVisibility(View.VISIBLE);
    colorAnim.start();
}

From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java

static Animation makeFadeAnimation(Context context, float start, float end) {
    AlphaAnimation anim = new AlphaAnimation(start, end);
    anim.setInterpolator(DECELERATE_CUBIC);
    anim.setDuration(ANIM_DUR);/*from  w  w  w .  j av  a  2  s  .c  o  m*/
    return anim;
}

From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java

static Animation makeOpenCloseAnimation(Context context, float startScale, float endScale, float startAlpha,
        float endAlpha) {
    AnimationSet set = new AnimationSet(false);
    ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    scale.setInterpolator(DECELERATE_QUINT);
    scale.setDuration(ANIM_DUR);/*from  w  ww .ja v a  2 s. co m*/
    set.addAnimation(scale);
    AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha);
    alpha.setInterpolator(DECELERATE_CUBIC);
    alpha.setDuration(ANIM_DUR);
    set.addAnimation(alpha);
    return set;
}

From source file:org.numixproject.hermes.activity.ConversationActivity.java

private void showConversationLayout() {
    // get the final radius for the clipping circle
    int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight());
    final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // create the animator for this view (the start radius is zero)
        Animator colorAnim;/*from   w  w  w.j  a  va  2  s  . c  om*/
        colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(),
                (int) roomsLayout.getTop(), 0, finalRadius);
        final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
        fadeAnim.setDuration(250);
        fadeAnim.setInterpolator(new AccelerateInterpolator());
        fadeAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                conversationLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                colorLayout.setVisibility(View.GONE);
                invalidateOptionsMenu();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        colorAnim.setInterpolator(new AccelerateInterpolator());
        colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationRepeat(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationEnd(android.animation.Animator animation) {
                colorLayout.startAnimation(fadeAnim);
            }

            @Override
            public void onAnimationCancel(android.animation.Animator animation) {
            }
        });

        colorLayout.setVisibility(View.VISIBLE);
        colorAnim.start();

    } else {
        conversationLayout.setVisibility(View.VISIBLE);
        conversationLayout.setAlpha(0.f);
        conversationLayout.setScaleX(0.f);
        conversationLayout.setScaleY(0.f);
        conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start();
    }
}