Example usage for android.view.animation Animation setFillEnabled

List of usage examples for android.view.animation Animation setFillEnabled

Introduction

In this page you can find the example usage for android.view.animation Animation setFillEnabled.

Prototype

public void setFillEnabled(boolean fillEnabled) 

Source Link

Document

If fillEnabled is true, the animation will apply the value of fillBefore.

Usage

From source file:Main.java

public static void setPraiseAnimation(Animation... animations) {
    for (Animation animation : animations) {
        animation.setFillAfter(true);//from   ww w.j  a  v a 2 s  .  co  m
        animation.setFillBefore(true);
        animation.setFillEnabled(true);
        animation.setDuration(50);
    }
}

From source file:Main.java

/**
 * Applies a fade in animation and set the visibility in
 * {@link View#VISIBLE}./*from w  w  w .  j a va 2 s.c o  m*/
 * @param view view to animate.
 */
public static void fadeInView(final View view) {
    if (view.getVisibility() != View.VISIBLE) {
        cancelAnimation(view);
        view.setVisibility(View.VISIBLE);
        Animation animation = android.view.animation.AnimationUtils.loadAnimation(view.getContext(),
                android.R.anim.fade_in);
        animation.setFillEnabled(true);
        animation.setFillBefore(true);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.clearAnimation();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        view.setAnimation(animation);
        animation.start();
    }
}

From source file:Main.java

/**
 * Applies a fade out animation and set the visibility in
 * {@link View#GONE}.//from  ww w  .  ja  v  a2s  . c o  m
 * @param view view to animate.
 */
public static void fadeOutView(final View view) {
    if (view.getVisibility() == View.VISIBLE) {
        cancelAnimation(view);
        Animation animation = android.view.animation.AnimationUtils.loadAnimation(view.getContext(),
                android.R.anim.fade_out);
        animation.setFillEnabled(true);
        animation.setFillBefore(true);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

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

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        view.setAnimation(animation);
        animation.start();
    }
}

From source file:Main.java

public static void slideToUp(View view) {
    Animation slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);

    slide.setDuration(400);/*from  ww w .  j a  v a 2 s.c  o  m*/
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    view.startAnimation(slide);

    slide.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade in.//from  w  w w. j a  va2s.co m
 */
public void fadeIn() {
    Animation anim = new AlphaAnimation(maxBrightness, minBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade out.//from   www.j a v a 2 s.c o m
 */
public void fadeOut() {
    this.view.setAlpha(1f);
    Animation anim = new AlphaAnimation(minBrightness, maxBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.skubit.comics.activities.ComicViewerActivity.java

@Override
public void toggleView() {
    if (mIsFullView) {
        toolbar.setVisibility(View.VISIBLE);
        toolbar.animate().translationY(0);

        mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_light));
        mIsFullView = false;/*from  ww w. ja va2  s .  co  m*/

        mSlider.setVisibility(View.VISIBLE);
        mSlider.animate().translationY(0);
        mSlider.setValue(mPager.getCurrentItem());

        final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_in);
        anim.setFillEnabled(true);
        anim.setFillAfter(true);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation arg0) {
                mPager.setDrawingCacheEnabled(true);
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                mPager.setScaleX(.83f);
                mPager.setScaleY(.83f);
                mPager.clearAnimation();
            }
        });

        mPager.setAnimation(anim);
        mPager.startAnimation(anim);

    } else {
        toolbar.animate().translationY(-toolbar.getHeight());
        toolbar.setLayoutAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                toolbar.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_dark));
        mIsFullView = true;

        mSlider.animate().translationY(mMainView.getHeight() + mSlider.getHeight());
        mSlider.setLayoutAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mSlider.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_out);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation arg0) {
                mPager.setScaleX(1f);
                mPager.setScaleY(1f);
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                mPager.clearAnimation();
            }
        });
        mPager.setAnimation(anim);
        mPager.startAnimation(anim);

    }
}

From source file:com.spoiledmilk.ibikecph.controls.SortableListView.java

void translate(View v, float deltaY, final boolean finalAnim) {
    float newY = posY + deltaY;
    if (animation != null && animation.isInitialized())
        animation.cancel();//from   w w  w  . j a  v a2  s  .  c  o m
    animation = new TranslateAnimation(0, 0, posY, newY);
    animation.setDuration(finalAnim ? 0 : 100);
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (!finalAnim) {
                animation.setFillEnabled(true);
                animation.setFillAfter(true);
            } else {
                view.clearAnimation();
                posY = 0;
            }
        }
    });

    posY = newY;

    v.startAnimation(animation);
}

From source file:de.grobox.transportr.trips.search.DirectionsFragment.java

private void swapLocations() {
    float toToY = fromCard.getY() - toCard.getY();
    Animation slideUp = new TranslateAnimation(RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF,
            0.0f, Animation.ABSOLUTE, toToY);
    slideUp.setDuration(400);// w ww .  j  a  v  a2 s  .co m
    slideUp.setFillAfter(true);
    slideUp.setFillEnabled(true);

    float fromToY = toCard.getY() - fromCard.getY();
    Animation slideDown = new TranslateAnimation(RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f,
            RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, fromToY);
    slideDown.setDuration(400);
    slideDown.setFillAfter(true);
    slideDown.setFillEnabled(true);

    fromCard.startAnimation(slideDown);
    toCard.startAnimation(slideUp);

    slideUp.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // swap location objects
            WrapLocation tmp = to.getLocation();
            if (from.isSearching()) {
                viewModel.findGpsLocation.setValue(null);
                // TODO: GPS currently only supports from location, so don't swap it for now
                viewModel.setToLocation(null);
            } else {
                viewModel.setToLocation(from.getLocation());
            }
            viewModel.setFromLocation(tmp);

            fromCard.clearAnimation();
            toCard.clearAnimation();

            viewModel.search();
        }
    });
}

From source file:com.emmasuzuki.quickreturnlistview.view.QuickReturnListView.java

private void animateQuickReturnViewToDest(final int destY) {
    // Pre-honeycomb style
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
            Animation.ABSOLUTE, 0, Animation.ABSOLUTE, destY - mQuickReturnView.getTop());
    animation.setFillEnabled(true);
    animation.setDuration(mSettleAnimationDuration);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override//from   w w w . j  ava  2  s. com
        public void onAnimationStart(Animation animation) {
            // Noop
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // TranslateAnimation does not change view's position, so
            // after the animation end, manually set quick return view position to destination
            setQuickReturnViewY(destY);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // Noop
        }
    });

    mQuickReturnView.startAnimation(animation);
}