android.view.animation.TranslateAnimation Java Examples

The following examples show how to use android.view.animation.TranslateAnimation. 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: MicrophoneRecorderView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
void display(float x, float y) {
  this.startPositionX = x;
  this.startPositionY = y;

  recordButtonFab.setVisibility(View.VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0));

  animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
                                            Animation.RELATIVE_TO_SELF, .5f,
                                            Animation.RELATIVE_TO_SELF, .5f));

  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
Example #2
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 #3
Source File: BookActivity.java    From AnimationApiDemos with Apache License 2.0 6 votes vote down vote up
private void useCodeAnimation(ViewAnimator pages) {
	// 用代码定义一个动画
	AnimationSet slideAnimationSet = new AnimationSet(true);

	// 平移动画
	TranslateAnimation slide = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT, 1f, Animation.RELATIVE_TO_PARENT,
			0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);

	// 缩放动画
	ScaleAnimation scale = new ScaleAnimation(10, 1, 10, 1);
	// 把平移和缩放动画加入动画集合
	slideAnimationSet.addAnimation(slide);
	slideAnimationSet.addAnimation(scale);

	// 持续时间设置为1000ms
	slideAnimationSet.setDuration(1000);

	// 设置动画
	pages.setInAnimation(slideAnimationSet);
}
 
Example #4
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private static AnimationSet startAlphaHideAnimation(final int DELAY, final View VIEW, boolean includeTransition) {
    final int ANIMATION_DURATION = 300;
    if (VIEW == null)
        return null;

    final Animation mAlphaAnimation = new AlphaAnimation(1f, 0f);
    mAlphaAnimation.setDuration(ANIMATION_DURATION);
    mAlphaAnimation.setFillAfter(true);

    final AnimationSet mHideAnimations = new AnimationSet(true);
    mHideAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mHideAnimations.setFillAfter(true);
    mHideAnimations.addAnimation(mAlphaAnimation);

    if (includeTransition) {
        final Animation mTransitionAnimation = new TranslateAnimation(0, 0, 0, VIEW.getHeight() / 2);
        mTransitionAnimation.setDuration(ANIMATION_DURATION);
        mTransitionAnimation.setFillAfter(false);

        mHideAnimations.addAnimation(mTransitionAnimation);
    }

    new Handler().postDelayed(() -> VIEW.startAnimation(mHideAnimations), DELAY);

    return mHideAnimations;
}
 
Example #5
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 #6
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
    final int ANIMATION_DURATION = 650;
    final int BASE_DELAY = 50;

    TranslateAnimation translationAnimation = new TranslateAnimation(0, 0, height, 0);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);

    final AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(translationAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animationSet.setFillAfter(true);
    animationSet.setFillBefore(true);
    animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);

    aCard.setAnimation(animationSet);
}
 
Example #7
Source File: PullRecyclerViewGroup.java    From Bailan with Apache License 2.0 6 votes vote down vote up
/** 
 * 位置还原 
 */  
private void recoverLayout() {  
  
    if (!isMoved) {  
        return;//如果没有移动布局,则跳过执行  
    }  
      
    for (int i = 0; i < mMoveViews.size(); i++) {  
        if (mMoveRects.get(i) != null) {
            TranslateAnimation anims = new TranslateAnimation(0, 0, mMoveViews.get(i).getTop(), mMoveRects.get(i).top);
            anims.setDuration(ANIM_TIME);
            mMoveViews.get(i).startAnimation(anims);
            mMoveViews.get(i).layout(mMoveRects.get(i).left, mMoveRects.get(i).top, mMoveRects.get(i).right, mMoveRects.get(i).bottom);

        }  
  
    }
    TranslateAnimation anim = new TranslateAnimation(0, 0, childView.getTop() - originalRect.top, 0);
    anim.setDuration(ANIM_TIME);
    childView.startAnimation(anim);

    childView.layout(originalRect.left, originalRect.top, originalRect.right, originalRect.bottom);

    isMoved = false;

}
 
Example #8
Source File: DragSortGridView.java    From WayHoo with Apache License 2.0 6 votes vote down vote up
private void moveView(int fromPosition, int toPosition) {
	if (DEBUG_LOG) {
		L.d(TAG, "moveView from:" + fromPosition + ",to:" + toPosition);
	}

	final View from = getView(fromPosition);
	final View to = getView(toPosition);

	final Rect fromRect = new Rect();
	getLayout(from, fromRect);
	final Rect toRect = new Rect();
	getLayout(to, toRect);

	Animation translate = new TranslateAnimation(0, toRect.left
			- fromRect.left, 0, toRect.top - fromRect.top);
	translate.setDuration(150);
	translate.setFillEnabled(true);
	translate.setFillBefore(true);
	translate.setFillAfter(true);
	translate.setAnimationListener(new MoveViewAnimationListener(from, to
			.getLeft(), to.getTop()));

	from.startAnimation(translate);
}
 
Example #9
Source File: TreeYMenu.java    From YMenuView with Apache License 2.0 6 votes vote down vote up
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {

    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());

    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //设置动画延时
    animationSet.setStartOffset(60*(getOptionPositionCount() - index));
    return animationSet;
}
 
Example #10
Source File: Circle8YMenu.java    From YMenuView with Apache License 2.0 6 votes vote down vote up
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //为不同的Option设置延时
    if (index % 2 == 0) {
        animationSet.setStartOffset(getOptionSD_AnimationDuration()/2);
    }
    return animationSet;
}
 
Example #11
Source File: Fragment_home.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 创建动画 平移动画直接传递偏移量
 *
 * @param startX
 * @param startY
 * @return
 */
private Animation createAnim(int startX, int startY) {
    int[] des = new int[2];
    imgCart.getLocationInWindow(des);
    AnimationSet set = new AnimationSet(false);
    Animation translationX = new TranslateAnimation(0, des[0] - startX, 0, 0);
    translationX.setInterpolator(new LinearInterpolator());
    Animation translationY = new TranslateAnimation(0, 0, 0, des[1] - startY);
    translationY.setInterpolator(new AccelerateInterpolator());
    Animation alpha = new AlphaAnimation(1, 0.5f);
    set.addAnimation(translationX);
    set.addAnimation(translationY);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example #12
Source File: WindowAnimationSpec.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public long calculateStatusBarTransitionStartTime() {
    TranslateAnimation openTranslateAnimation = findTranslateAnimation(mAnimation);
    if (openTranslateAnimation != null) {

        // Some interpolators are extremely quickly mostly finished, but not completely. For
        // our purposes, we need to find the fraction for which ther interpolator is mostly
        // there, and use that value for the calculation.
        float t = findAlmostThereFraction(openTranslateAnimation.getInterpolator());
        return SystemClock.uptimeMillis()
                + openTranslateAnimation.getStartOffset()
                + (long)(openTranslateAnimation.getDuration() * t)
                - STATUS_BAR_TRANSITION_DURATION;
    } else {
        return SystemClock.uptimeMillis();
    }
}
 
Example #13
Source File: CaptureActivity.java    From ZBarScanProj with MIT License 6 votes vote down vote up
private void initViews() {
	autoFocusHandler = new Handler();
	mCameraManager = new CameraManager(this);
	try {
		mCameraManager.openDriver();
	} catch (IOException e) {
		e.printStackTrace();
	}

	mCamera = mCameraManager.getCamera();
	mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
	scanPreview.addView(mPreview);

	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
			0.85f);
	animation.setDuration(3000);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.REVERSE);
	scanLine.startAnimation(animation);
}
 
Example #14
Source File: CaptureActivity.java    From ZXingProject with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_capture);

	scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
	scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
	scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
	scanLine = (ImageView) findViewById(R.id.capture_scan_line);

	inactivityTimer = new InactivityTimer(this);
	beepManager = new BeepManager(this);

	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
			0.9f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);
}
 
Example #15
Source File: ScanLoginActivity.java    From Android with MIT License 6 votes vote down vote up
@Override
public void initView() {
    mActivity = this;
    setViewFind(capturePreview, captureCropView, captureContainer);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    animation.setDuration(1500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    captureScanLine.startAnimation(animation);
    //setLineAnimation(captureScanLine);

    setPresenter(new ScanLoginPresenter(this));
    presenter.start();
}
 
Example #16
Source File: MicrophoneRecorderView.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public void display(float x) {
  this.startPositionX = x;
  this.lastPositionX  = x;

  recordButtonFab.setVisibility(View.VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, -.25f,
                                                Animation.RELATIVE_TO_SELF, -.25f));

  animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
                                            Animation.RELATIVE_TO_SELF, .5f,
                                            Animation.RELATIVE_TO_SELF, .5f));

  animation.setFillBefore(true);
  animation.setFillAfter(true);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
Example #17
Source File: HomeScreenActivity.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
private AnimationSet getEntryAnimation(int inAnimationDuration) {
    //In
    AnimationSet 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(inAnimationDuration);

    return mInAnimationSet;

}
 
Example #18
Source File: ViewUtils.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
public static void hideViewFromBottom(final View view) {
    if (view.getVisibility() == View.INVISIBLE) {
        return;
    }
    int height = view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, height);
    translateAnimation.setDuration(ANIMATION_DURATION);
    translateAnimation.setInterpolator(sAnimationInterpolator);
    translateAnimation.setAnimationListener(new AnimationAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            view.setVisibility(View.INVISIBLE);
        }
    });
    view.startAnimation(translateAnimation);
}
 
Example #19
Source File: MicrophoneRecorderView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
void hide() {
  recordButtonFab.setTranslationX(0);
  recordButtonFab.setTranslationY(0);
  if (recordButtonFab.getVisibility() != VISIBLE) return;

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, lastOffsetX,
                                                        Animation.ABSOLUTE, 0,
                                                        Animation.ABSOLUTE, lastOffsetY,
                                                        Animation.ABSOLUTE, 0);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
Example #20
Source File: RxTextViewVertical.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
public void setAnimTime(long animDuration) {
    setFactory(this);
    Animation in = new TranslateAnimation(0, 0, animDuration, 0);
    in.setDuration(animDuration);
    in.setInterpolator(new AccelerateInterpolator());
    Animation out = new TranslateAnimation(0, 0, 0, -animDuration);
    out.setDuration(animDuration);
    out.setInterpolator(new AccelerateInterpolator());
    setInAnimation(in);
    setOutAnimation(out);
}
 
Example #21
Source File: ContainerViewManager.java    From Paginize with MIT License 5 votes vote down vote up
private Animation createAnimation(int fromXType, float fromXValue, int toXType, float toXValue, Animation.AnimationListener animationListener) {
    Animation animation = new TranslateAnimation(fromXType, fromXValue, toXType, toXValue
            , Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
    animation.setDuration(mPageManager.getTransitionAnimationDuration());
    animation.setInterpolator(new DecelerateInterpolator(2.0f));
    animation.setAnimationListener(animationListener);
    return animation;
}
 
Example #22
Source File: AwesomeFragment.java    From AndroidNavigation with MIT License 5 votes vote down vote up
private void animateDownOut(@NonNull final View contentView) {
    TranslateAnimation translate = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f
    );
    AlphaAnimation alpha = new AlphaAnimation(1, 0);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(translate);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(200);
    set.setFillAfter(true);
    set.setAnimationListener(createAnimationListener(contentView));
    contentView.startAnimation(set);
}
 
Example #23
Source File: AnimUtils.java    From Dagger2-Sample with MIT License 5 votes vote down vote up
public static Animation createBgImageInAnimation(int fromX, int toX, int transitionDuration) {
    TranslateAnimation translate = new TranslateAnimation(fromX, toX, 0, 0);
    translate.setDuration(transitionDuration);

    AnimationSet set = new AnimationSet(true);
    set.setInterpolator(new DecelerateInterpolator());
    set.addAnimation(translate);
    return set;
}
 
Example #24
Source File: LogInActivity.java    From PracticeCode with Apache License 2.0 5 votes vote down vote up
private void initAnimation() {
    Animation logInAnimation = new TranslateAnimation(0, 0, 0, 400);
    logInAnimation.setFillAfter(true);
    logInAnimation.setDuration(1300);
    logInAnimation.setInterpolator(this,
            android.R.anim.accelerate_decelerate_interpolator);

    FadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
    FadeOutAnimation.setDuration(600);
    FadeOutAnimation.setFillAfter(true);

    FadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    FadeInAnimation.setDuration(600);
    FadeInAnimation.setFillAfter(true);

    Animation flashFadeInnOut = new AlphaAnimation(0.0f, 1.0f);
    flashFadeInnOut.setDuration(1000);
    flashFadeInnOut.setFillAfter(true);
    flashFadeInnOut.setInterpolator(this,
            android.R.anim.accelerate_decelerate_interpolator);
    flashFadeInnOut.setRepeatMode(Animation.REVERSE);
    flashFadeInnOut.setRepeatCount(Animation.INFINITE);

    FlashFadeInnOutSet = new AnimationSet(true);
    FlashFadeInnOutSet.addAnimation(flashFadeInnOut);
    FlashFadeInnOutSet.addAnimation(logInAnimation);

    logInAnimationReverse = new TranslateAnimation(0, 0, icon.getY(), 0);
    logInAnimationReverse.setDuration(2000);
    logInAnimationReverse.setInterpolator(this, android.R.anim.decelerate_interpolator);
    logInAnimationReverse.setFillAfter(true);
}
 
Example #25
Source File: NormalListDialog.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void init() {
    widthScale(0.8f);

    /** LayoutAnimation */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 2f, Animation.RELATIVE_TO_SELF,
            0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(550);

    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
 
Example #26
Source File: EasyRecyclerView.java    From BookReader with Apache License 2.0 5 votes vote down vote up
public void showTipView(String tip) {
    tipView.setText(tip);
    Animation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    mShowAction.setDuration(500);
    tipView.startAnimation(mShowAction);
    tipView.setVisibility(View.VISIBLE);
}
 
Example #27
Source File: ActionBarSeg.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void trans(long dura, float frX, float toX) {
    TranslateAnimation animation = new TranslateAnimation(frX, toX, 0.0F, 0.0F);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(dura);
    animation.setFillAfter(true);
    vTrans.startAnimation(animation);
}
 
Example #28
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 #29
Source File: MenuAnimationUtils.java    From Android-tv-widget with Apache License 2.0 5 votes vote down vote up
/**
 * 从左到右显示菜单.
 */
public static Animation showAnimation() {
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(1000);
    return animation;
}
 
Example #30
Source File: ClearWriteEditText.java    From sealrtc-android with MIT License 5 votes vote down vote up
/**
 * 晃动动画
 *
 * @param counts 半秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}