Example usage for android.view.animation TranslateAnimation setFillAfter

List of usage examples for android.view.animation TranslateAnimation setFillAfter

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation setFillAfter.

Prototype

public void setFillAfter(boolean fillAfter) 

Source Link

Document

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

Usage

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

private Animation createTranslationOutAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 0, type, 1);
    an.setDuration(TRANSLATE_DURATION);/* w  w  w.j  a  v a  2  s. co m*/
    an.setFillAfter(true);
    return an;
}

From source file:com.plusub.lib.example.view.TabView.java

/**
 * ?/*from  w  w w. j a  v  a2  s  . c o m*/
 * @param arg0
 */
private void moveCursor(int arg0) {
    TranslateAnimation animation = new TranslateAnimation(mCursorCurPosition, arg0 * mScreenWidth / tabCount,
            Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF);
    mCursorCurPosition = arg0 * mScreenWidth / tabCount;
    animation.setDuration(200);
    animation.setInterpolator(new LinearInterpolator());
    animation.setFillAfter(true);
    mIvCursor.startAnimation(animation);
}

From source file:cn.org.eshow.framwork.view.sliding.AbBottomTabView.java

/**
 * ??.//from  ww w.j av a 2s  .  co m
 *
 * @param v the v
 * @param startX the start x
 * @param toX the to x
 * @param startY the start y
 * @param toY the to y
 */
public void imageSlide(View v, int startX, int toX, int startY, int toY) {
    TranslateAnimation anim = new TranslateAnimation(startX, toX, startY, toY);
    anim.setDuration(100);
    anim.setFillAfter(true);
    v.startAnimation(anim);
}

From source file:org.noorganization.instalist.view.activity.MainShoppingListView.java

private void slideDrawer(float _MoveFactor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mFrameLayout.setTranslationX(_MoveFactor);
    } else {//from   ww w .ja  v  a  2 s  .  c  o  m
        TranslateAnimation anim = new TranslateAnimation(mLastDrawerTranslate, _MoveFactor, 0.0f, 0.0f);
        anim.setDuration(0);
        anim.setFillAfter(true);
        mFrameLayout.startAnimation(anim);
        mLastDrawerTranslate = _MoveFactor;
    }
}

From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java

/**
 * Provides the ability to programmatically alter whether the scrollbar
 * should hide after a period of inactivity or not.
 * @param hide sets whether the bar should hide or not.
 *///from   w w  w  . j a v  a2 s.  c  o m
public MaterialScrollBar setAutoHide(Boolean hide) {
    if (!hide) {
        fade.interrupt();
        TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f);
        anim.setFillAfter(true);
        startAnimation(anim);
    } else if (!this.hide) {
        fade.start();
    }
    this.hide = hide;
    return this;
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void initializeFab(View rootView) {
    final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container);
    final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar);
    final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar);
    Fab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override//www.ja  va  2 s .c o m
        public void onClick(View v) {

            //Menu Button Icon Animation
            //Setting up necessary variables
            long animationDuration = 500;
            float containerHeight = buttonContainer.getHeight();
            float containerCenterY = containerHeight / 2;
            float containerCenterX = buttonContainer.getWidth() / 2;
            float topBarCenter = topBar.getTop() + topBar.getHeight() / 2;
            float widthOfBar = topBar.getWidth();
            float heightOfBar = topBar.getHeight();
            final float distanceBetweenBars = (containerCenterY - topBarCenter);

            /**
             *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties
             *and objects at the same time. Also, will try to break intialization into smaller functions.
             */

            //Setting up animations of hamburger bars and rotation

            /**
             * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar.
             * Y Translation is 1/2 the height of the hamburger bar minus the distance.
             * Subtracting the distance from the height because the distance between bars is
             * calculated of the exact center of the button.
             * With out the subtraction the bar would translate slightly below the middle bar.
             */
            float yTranslation = heightOfBar / 2 - distanceBetweenBars;
            float xTranslation = widthOfBar / 2 + heightOfBar / 2;
            TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars);
            topBarTranslationAnim.setDuration((long) (animationDuration * 0.8));
            topBarTranslationAnim.setFillAfter(true);

            //Animation for bottom hamburger bar. Translates and Rotates to create 'X'
            AnimationSet bottomBarAnimation = new AnimationSet(true);
            bottomBarAnimation.setFillAfter(true);

            //Rotate to create cross. (The cross becomes the X after the button rotation completes"
            RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f,
                    Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f);
            bottomBarRotationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarRotationAnimation);

            //Translate to correct X alignment
            TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE,
                    -yTranslation);
            bottomBarTranslationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarTranslationAnimation);

            //Button Specific Animations
            //Rotate Button Container
            RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            containerRotationAnimation.setDuration(animationDuration);
            containerRotationAnimation.setFillAfter(true);

            //Animate change of button color between Active and Disabled colors that have been
            //defined in color.xml
            int activeColor = getResources().getColor(R.color.active_button);
            int disabledColor = getResources().getColor(R.color.disabled_button);

            //Need to use ValueAnimator because property animator does not support BackgroundTint
            ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor);
            buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue()));
                }
            });
            buttonColorAnimation.setDuration(animationDuration);

            //Start all the animations
            topBar.startAnimation(topBarTranslationAnim);
            bottomBar.startAnimation(bottomBarAnimation);
            buttonContainer.startAnimation(containerRotationAnimation);
            buttonColorAnimation.start();

            //Toogle mMenu open and closed
            if (mMenu.isOpen()) {
                //If mMenu is open, do the reverse of the animation
                containerRotationAnimation
                        .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator()));
                mMenu.close();
            } else {
                bottomBarAnimation.setInterpolator(new AccelerateInterpolator());
                mMenu.open();
            }
        }
    });
}

From source file:com.sahildave.snackbar.SnackBar.java

private AnimationSet getEntryAnimation() {
    //In/*from  ww  w .  j av a 2 s  .  c  o m*/
    mInAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(IN_ANIMATION_DURATION);

    return mInAnimationSet;

}

From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java

/**
 * @param context The app's context//from  w ww .  j  a  va2s. c  om
 * @param recyclerView The recyclerView to which you wish to link the scrollBar
 * @param lightOnTouch Should the handle always be coloured or should it light up on touch and turn grey when released
 */
public MaterialScrollBar(Context context, RecyclerView recyclerView, boolean lightOnTouch) {
    super(context);

    if (!isInEditMode()) {
        a = (Activity) context;
    }

    background = new View(context);
    LayoutParams lp = new RelativeLayout.LayoutParams(Utils.getDP(8, this), LayoutParams.MATCH_PARENT);
    lp.addRule(ALIGN_PARENT_RIGHT);
    background.setLayoutParams(lp);
    background.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
    ViewHelper.setAlpha(background, 0.4F);

    handle = new View(context);
    lp = new RelativeLayout.LayoutParams(Utils.getDP(8, this), Utils.getDP(48, this));
    lp.addRule(ALIGN_PARENT_RIGHT);
    handle.setLayoutParams(lp);

    this.lightOnTouch = lightOnTouch;
    int colourToSet;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        handleColour = fetchAccentColour(context);
    } else {
        handleColour = Color.parseColor("#9c9c9c");
    }
    if (lightOnTouch) {
        colourToSet = Color.parseColor("#9c9c9c");
    } else {
        colourToSet = handleColour;
    }
    handle.setBackgroundColor(colourToSet);

    addView(background);
    addView(handle);

    setId(R.id.reservedNamedId);
    LayoutParams layoutParams = new LayoutParams(Utils.getDP(20, this), ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(ALIGN_RIGHT, recyclerView.getId());
    layoutParams.addRule(ALIGN_TOP, recyclerView.getId());
    layoutParams.addRule(ALIGN_BOTTOM, recyclerView.getId());
    ((ViewGroup) recyclerView.getParent()).addView(this, layoutParams);
    recyclerView.addOnScrollListener(new ScrollListener(this));
    this.recyclerView = recyclerView;

    setTouchIntercept();

    fade = new BarFade(this);
    fade.start();

    TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.0f);
    anim.setFillAfter(true);
    startAnimation(anim);
}

From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java

/**
 * Animates the bar into view/*from   w w w .j av  a  2 s . c o m*/
 */
private void fadeIn() {
    if (hidden && hide && !totallyHidden) {
        hidden = false;
        TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f);
        anim.setDuration(500);
        anim.setFillAfter(true);
        startAnimation(anim);

    }
}

From source file:com.sahildave.snackbar.SnackBar.java

private AnimationSet getExitAnimation() {
    //Out/*from ww w  .  jav a  2 s . co m*/
    mOutAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 1.0f);

    mSlideOutAnimation.setFillAfter(true);

    AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
    mFadeOutAnimation.setFillAfter(true);

    mOutAnimationSet.addAnimation(mSlideOutAnimation);
    mOutAnimationSet.addAnimation(mFadeOutAnimation);

    mOutAnimationSet.setDuration(OUT_ANIMATION_DURATION);

    return mOutAnimationSet;
}