android.view.animation.TranslateAnimation#setFillBefore()源码实例Demo

下面列出了android.view.animation.TranslateAnimation#setFillBefore() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bither-android   文件: PinCodeEnterView.java
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);
}
 
源代码2 项目: CameraV   文件: UIHelpers.java
@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);
	}
}
 
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);
}
 
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;
}
 
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;
}
 
源代码6 项目: ripple   文件: AnimationHelpers.java
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);
    }
}