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

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

源代码1 项目: Android-Basics-Codes   文件: MainActivity.java
public void translate(View v){
		//����ƽ�Ʋ��䶯��
//		TranslateAnimation ta = new TranslateAnimation(-100, 100, -50, 50);
		
		ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -3, Animation.RELATIVE_TO_SELF, 3, 
				Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
		//���ö�������ʱ��
		ta.setDuration(2000);
		//�����ظ����Ŵ���
		ta.setRepeatCount(1);
		//�����ظ�����ģʽ
		ta.setRepeatMode(Animation.REVERSE);
		//���ö���ͣ���ڽ���λ��
		ta.setFillAfter(true);
		
		iv.startAnimation(ta);
	}
 
源代码2 项目: Bailan   文件: ParallaxRecyclerAdapter.java
/**
 * Translates the adapter in Y
 *
 * @param of offset in px
 */
public void translateHeader(float of) {
    float ofCalculated = of * mScrollMultiplier;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && of < mHeader.getHeight()) {
        mHeader.setTranslationY(ofCalculated);
    } else if (of < mHeader.getHeight()) {
        TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated);
        anim.setFillAfter(true);
        anim.setDuration(0);
        mHeader.startAnimation(anim);
    }
    mHeader.setClipY(Math.round(ofCalculated));
    if (mParallaxScroll != null) {
        final RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(0);
        float left;
        if (holder != null) {
            left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * mScrollMultiplier)));
        }else {
            left = 1;
        }
        mParallaxScroll.onParallaxScroll(left, of, mHeader);
    }
}
 
源代码3 项目: QuickReturn   文件: QuickReturnTargetView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void translateTo(final int translationY) {
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    final TranslateAnimation anim = new TranslateAnimation(0, 0, translationY, translationY);
    anim.setFillAfter(true);
    anim.setDuration(0);
    quickReturnView.startAnimation(anim);
  } else {
    quickReturnView.setTranslationY(translationY);
  }
}
 
源代码4 项目: star-zone-android   文件: AnimUtils.java
public static TranslateAnimation getPortraitTranslateAnimation(int start, int end, int durationMillis) {
    TranslateAnimation translateAnimation = new TranslateAnimation(0.0F, 0.0F, (float) start, (float) end);
    translateAnimation.setDuration((long) durationMillis);
    translateAnimation.setFillEnabled(true);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
}
 
源代码5 项目: moviedb-android   文件: MovieDetails.java
/**
 * Creates animation for the gallery, homePage and trailer Icons with down direction.
 */
public void createIconDownAnimation(float dy) {
    iconDownAnimation = new TranslateAnimation(0, 0, 0, ((scale * 67.3f) + 0.5f + (dy * scale)) * iconDirection);
    iconDownAnimation.setDuration(250);
    iconDownAnimation.setFillAfter(false);
    iconDownAnimation.setAnimationListener(iconDownAnimationListener);
}
 
源代码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);
    }
}
 
源代码7 项目: Lay-s   文件: AnimationUtils.java
/**
 * 位移 Translate
 */
public static Animation getTranslateAnimation(float fromXDelta,
                                              float toXDelta, float fromYDelta, float toYDelta,
                                              long durationMillis) {
    TranslateAnimation translate = new TranslateAnimation(fromXDelta,
            toXDelta, fromYDelta, toYDelta);
    translate.setDuration(durationMillis);
    translate.setFillAfter(true);
    return translate;
}
 
private TranslateAnimation createTranslateAnimation(Point oldOffset, Point newOffset) {
    TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, oldOffset.x,
            Animation.ABSOLUTE, newOffset.x,
            Animation.ABSOLUTE, oldOffset.y,
            Animation.ABSOLUTE, newOffset.y);
    translate.setDuration(ANIMATION_DURATION);
    translate.setFillEnabled(true);
    translate.setFillAfter(true);
    translate.setInterpolator(new AccelerateDecelerateInterpolator());
    return translate;
}
 
源代码9 项目: SimpleProject   文件: ViewAnimationUtil.java
public static void translate(View view, int startX, int startY, int endX, int endY, int duration, Interpolator interpolator) {
	TranslateAnimation animation = new TranslateAnimation(startX, endX, startY, endY);
	animation.setDuration(duration);
	animation.setFillAfter(true);
	animation.setInterpolator(interpolator);
	view.startAnimation(animation);
}
 
源代码10 项目: moviedb-android   文件: CastDetails.java
/**
 * Creates animation for the gallery and homePage Icons with up direction.
 */
public void createIconUpAnimation(float dy, int delay) {
    iconUpAnimation = new TranslateAnimation(0, 0, 0, (-(scale * 67.3f) + 0.5f - (dy * scale)) * iconDirection);
    iconUpAnimation.setDuration(250);
    iconUpAnimation.setFillAfter(false);
    iconUpAnimation.setStartOffset(delay);
    iconUpAnimation.setAnimationListener(iconUpAnimationListener);
}
 
源代码11 项目: BarrageView   文件: BarrageView.java
private TranslateAnimation generateTranslateAnim(BarrageItem item, int leftMargin) {
    TranslateAnimation anim = new TranslateAnimation(leftMargin, -item.textMeasuredWidth, 0, 0);
    anim.setDuration(item.moveSpeed);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setFillAfter(true);
    return anim;
}
 
源代码12 项目: UltimateAndroid   文件: SpanVariableGridView.java
protected final void translateChild(View v, Point prev, Point now) {

        TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, -now.x + prev.x, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -now.y
                + prev.y, Animation.ABSOLUTE, 0);
        translate.setInterpolator(new AccelerateInterpolator(4f));
        translate.setDuration(350);
        translate.setFillEnabled(false);
        translate.setFillAfter(false);

        v.clearAnimation();
        v.startAnimation(translate);
    }
 
源代码13 项目: JianshuApp   文件: SmartSwitchButton.java
private void startAnim() {
    this.isPlayingAnim = true;
    int distance = this.mLine.getMeasuredWidth() - this.mCircle.getMeasuredWidth();
    TranslateAnimation anim = new TranslateAnimation(0.0f, this.isChecked ? (float) (-distance) : (float) distance, 0.0f, 0.0f);
    anim.setDuration(40);
    anim.setFillAfter(false);
    anim.setAnimationListener(this);
    this.mCircle.startAnimation(anim);
}
 
源代码14 项目: Moring-Alarm   文件: FragWether.java
private void initIconAnimation(View view, int delay) {
    TranslateAnimation ta=new TranslateAnimation(Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,0f,
            Animation.RELATIVE_TO_PARENT,1f,Animation.RELATIVE_TO_SELF,0f);
    ta.setDuration(1000);
    ta.setStartOffset(delay);
    ta.setFillAfter(true);
    view.startAnimation(ta);
}
 
源代码15 项目: UltimateAndroid   文件: ParallaxListViewHelper.java
@Override
protected void translatePreICS(View view, float offset) {
	TranslateAnimation ta = new TranslateAnimation(0, 0, offset, offset);
	ta.setDuration(0);
	ta.setFillAfter(true);
	view.setAnimation(ta);
	ta.start();
}
 
源代码16 项目: NetEasyNews   文件: ChannelAdapter.java
private TranslateAnimation getTranslateAnimator(float targetX, float targetY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0f,
            Animation.ABSOLUTE, targetX,
            Animation.RELATIVE_TO_SELF, 0f,
            Animation.ABSOLUTE, targetY);
    // RecyclerView默认移动动画250ms 这里设置360ms 是为了防止在位移动画结束后 remove(view)过早 导致闪烁
    translateAnimation.setDuration(360);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
}
 
源代码17 项目: moviedb-android   文件: TVDetails.java
/**
 * Creates animation for the gallery and homePage Icons with down direction.
 */
public void createIconDownAnimation(float dy) {
    iconDownAnimation = new TranslateAnimation(0, 0, 0, ((scale * 67.3f) + 0.5f + (dy * scale)) * iconDirection);
    iconDownAnimation.setDuration(250);
    iconDownAnimation.setFillAfter(false);
    iconDownAnimation.setAnimationListener(iconDownAnimationListener);
}
 
源代码18 项目: lunzi   文件: AnimationController.java
public static void viticalIn(View view, long durationMillis, long delayMillis) {
    TranslateAnimation animation = new TranslateAnimation(rela2, 0, rela2, 0, rela2, 1, rela2, 0);
    animation.setFillAfter(true);
    baseIn(view, animation, durationMillis, delayMillis);
}
 
源代码19 项目: letv   文件: ChannelFragmentAdapter.java
private TranslateAnimation getTranslateAnimator(float targetX, float targetY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(1, 0.0f, 0, targetX, 1, 0.0f, 0, targetY);
    translateAnimation.setDuration(ANIM_TIME);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
}
 
private void initAnimations() {
	mTurnupAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mTurnupAnimation.setInterpolator(new LinearInterpolator());
	mTurnupAnimation.setDuration(500);
	mTurnupAnimation.setFillAfter(true);

	mTurndownAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mTurndownAnimation.setInterpolator(new LinearInterpolator());
	mTurndownAnimation.setDuration(500);
	mTurndownAnimation.setFillAfter(true);

	mTranslateAnimationOne = new TranslateAnimation(0, 100, 0, 100);
	mTranslateAnimationOne
			.setInterpolator(new AccelerateDecelerateInterpolator());
	mTranslateAnimationOne.setDuration(1000);
	mTranslateAnimationOne.setFillAfter(true);

	mTranslateAnimationTwo = new TranslateAnimation(100, 100, 0, 100);
	mTranslateAnimationTwo
			.setInterpolator(new AccelerateDecelerateInterpolator());
	mTranslateAnimationTwo.setDuration(1000);
	mTranslateAnimationTwo.setFillAfter(true);

	mAlphaAnimationOne = new AlphaAnimation(1, 0);
	mAlphaAnimationOne.setDuration(500);
	mAlphaAnimationOne.setFillAfter(true);

	mAlphaAnimationTwo = new AlphaAnimation(0, 1);
	mAlphaAnimationTwo.setDuration(1000);
	mAlphaAnimationTwo.setStartOffset(500);
	mAlphaAnimationTwo.setFillAfter(true);

	mAlphaAnimationSet = new AnimationSet(false);
	mAlphaAnimationSet.addAnimation(mAlphaAnimationOne);
	mAlphaAnimationSet.addAnimation(mAlphaAnimationTwo);
	mAlphaAnimationSet.setDuration(5000);

	mAlphaAnimationSet.setFillAfter(true);

	mScaleAnimation = new ScaleAnimation(1, 1.5f, 1, 1.5f);
	mScaleAnimation.setDuration(1000);
	mScaleAnimation.setFillAfter(true);

}