Example usage for android.view.animation AnimationUtils makeOutAnimation

List of usage examples for android.view.animation AnimationUtils makeOutAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils makeOutAnimation.

Prototype

public static Animation makeOutAnimation(Context c, boolean toRight) 

Source Link

Document

Make an animation for objects becoming invisible.

Usage

From source file:com.soomla.example.ExampleSocialActivity.java

private void showView(final View view, boolean show) {
    final Animation animation = show ? AnimationUtils.makeInAnimation(view.getContext(), true)
            : AnimationUtils.makeOutAnimation(view.getContext(), true);
    animation.setFillAfter(true);//from   w  w w  .  j  a v a  2  s .  c o m
    animation.setDuration(500);
    view.startAnimation(animation);
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public void setViewVisibility(final boolean visible, final boolean allowAnimation, int... ids) {
    for (int id : ids) {
        final View v = findViewById(id);
        if (v != null && visible != (v.getVisibility() == View.VISIBLE)) {
            if (allowAnimation) {
                Animation anim;/*from   w w w  .  ja  v  a2  s .  com*/
                if (visible)
                    anim = AnimationUtils.makeInAnimation(getApplicationContext(), true);
                else
                    anim = AnimationUtils.makeOutAnimation(getApplicationContext(), false);
                anim.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        if (visible)
                            v.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        if (!visible)
                            v.setVisibility(View.GONE);
                        else
                            v.setVisibility(View.VISIBLE);
                    }
                });
                v.startAnimation(anim);
            } else
                v.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    }
}