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

The following examples show how to use android.view.animation.TranslateAnimation#setFillAfter() . 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: ParallaxRecyclerAdapter.java    From Bailan with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
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);
	}
 
Example 3
Source File: QuickReturnTargetView.java    From QuickReturn with MIT License 5 votes vote down vote up
@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);
  }
}
 
Example 4
Source File: TVDetails.java    From moviedb-android with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: ChannelAdapter.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: ParallaxListViewHelper.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 7
Source File: FragWether.java    From Moring-Alarm with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: SmartSwitchButton.java    From JianshuApp with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: SpanVariableGridView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example 10
Source File: BarrageView.java    From BarrageView with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: CastDetails.java    From moviedb-android with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: ViewAnimationUtil.java    From SimpleProject with MIT License 5 votes vote down vote up
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);
}
 
Example 13
Source File: DragDropGrid.java    From android-draggable-viewpager with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: AnimationUtils.java    From Lay-s with MIT License 5 votes vote down vote up
/**
 * 位移 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;
}
 
Example 15
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);
    }
}
 
Example 16
Source File: MovieDetails.java    From moviedb-android with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: AnimUtils.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 18
Source File: ChannelFragmentAdapter.java    From letv with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 19
Source File: AnimationController.java    From lunzi with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 20
Source File: BasicAnimationDemoActivity.java    From AnimationApiDemos with Apache License 2.0 4 votes vote down vote up
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);

}