Java Code Examples for android.view.animation.TranslateAnimation#setFillBefore()

The following examples show how to use android.view.animation.TranslateAnimation#setFillBefore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PinCodeEnterView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public void animateToNext() {
    et.setEnabled(false);
    int totalWidth = getWidth();
    int dvWidth = dv.getWidth();
    int animDistance = (totalWidth - dvWidth) / 2 + dvWidth;
    TranslateAnimation animOut = new TranslateAnimation(0, -animDistance, 0, 0);
    animOut.setInterpolator(new AccelerateDecelerateInterpolator());
    animOut.setFillAfter(true);
    animOut.setDuration(AnimDuration);
    TranslateAnimation animIn = new TranslateAnimation(animDistance, 0, 0, 0);
    animIn.setInterpolator(new AccelerateDecelerateInterpolator());
    animIn.setFillBefore(true);
    animIn.setDuration(AnimDuration);
    animIn.setAnimationListener(animateToNextListener);
    dvNew.setVisibility(View.VISIBLE);
    dv.startAnimation(animOut);
    dvNew.startAnimation(animIn);
}
 
Example 2
Source File: UIHelpers.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("NewApi")
public static void translateY(final View view, float fromY, float toY, long duration)
{
	if (Build.VERSION.SDK_INT >= 12)
	{
		if (duration == 0)
			view.setTranslationY(toY);
		else
			view.animate().translationY(toY).setDuration(duration).start();
	}
	else
	{
		TranslateAnimation translate = new TranslateAnimation(0, 0, fromY, toY);
		translate.setDuration(duration);
		translate.setFillEnabled(true);
		translate.setFillBefore(true);
		translate.setFillAfter(true);
		addAnimation(view, translate);
	}
}
 
Example 3
Source File: MultiColumnPullToRefreshListView.java    From EverMemo with MIT License 6 votes vote down vote up
private void bounceBackHeader(){
	int yTranslate = state == State.REFRESHING ?
			header.getHeight() - headerContainer.getHeight() :
				-headerContainer.getHeight() - headerContainer.getTop();

			bounceAnimation = new TranslateAnimation(
					TranslateAnimation.ABSOLUTE, 0,
					TranslateAnimation.ABSOLUTE, 0,
					TranslateAnimation.ABSOLUTE, 0,
					TranslateAnimation.ABSOLUTE, yTranslate);

			bounceAnimation.setDuration(BOUNCE_ANIMATION_DURATION);
			bounceAnimation.setFillEnabled(true);
			bounceAnimation.setFillAfter(false);
			bounceAnimation.setFillBefore(true);
			//bounceAnimation.setInterpolator(new OvershootInterpolator(BOUNCE_OVERSHOOT_TENSION));
			bounceAnimation.setAnimationListener(new HeaderAnimationListener(yTranslate));
			startAnimation(bounceAnimation);
}
 
Example 4
Source File: CommonViewAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 5 votes vote down vote up
private Animation getTranslateAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2,
            0, getHeight() * 2);
    translateAnimation.setDuration(2000);
    translateAnimation.setRepeatCount(2);
    translateAnimation.setFillAfter(true);
    translateAnimation.setFillBefore(false);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    return translateAnimation;
}
 
Example 5
Source File: CommonViewAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private Animation getTranslateAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2,
            0, getHeight() * 2);
    translateAnimation.setDuration(2000);
    translateAnimation.setRepeatCount(2);
    translateAnimation.setFillAfter(true);
    translateAnimation.setFillBefore(false);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    return translateAnimation;
}
 
Example 6
Source File: AnimationHelpers.java    From ripple with GNU General Public License v3.0 5 votes vote down vote up
public static void translateY(final View view, float fromY, float toY, long duration) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0)
            view.setTranslationY(toY);
        else
            view.animate().translationY(toY).setDuration(duration).start();
    } else {
        TranslateAnimation translate = new TranslateAnimation(0, 0, fromY, toY);
        translate.setDuration(duration);
        translate.setFillEnabled(true);
        translate.setFillBefore(true);
        translate.setFillAfter(true);
        addAnimation(view, translate);
    }
}