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

The following examples show how to use android.view.animation.TranslateAnimation#setInterpolator() . 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: EBrowserWidget.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean exitMySpace(View view) {
    if (view.getParent() == this) {
        mBroWindow.setVisibility(VISIBLE);
        TranslateAnimation anim = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 1.0f);
        anim.setDuration(300);
        DecelerateInterpolator di = new DecelerateInterpolator();
        anim.setInterpolator(di);
        view.startAnimation(anim);
        removeView(view);
        return true;
    }
    return false;
}
 
Example 3
Source File: SlidePageAnimator.java    From Paginize with MIT License 6 votes vote down vote up
private void initAnimations() {
  DecelerateInterpolator interpolator = new DecelerateInterpolator(3.0f);
  mPushInFromRightAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0
      , Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
  mPushInFromRightAnimation.setInterpolator(interpolator);
  mPushInFromRightAnimation.setDuration(ANIMATION_DURATION);
  mPullOutFromLeftAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1
      , Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
  mPullOutFromLeftAnimation.setInterpolator(interpolator);
  mPullOutFromLeftAnimation.setDuration(ANIMATION_DURATION);
  mPushInFromLeftAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0
      , Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
  mPushInFromLeftAnimation.setInterpolator(interpolator);
  mPushInFromLeftAnimation.setDuration(ANIMATION_DURATION);
  mPullOutFromRightAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1
      , Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
  mPullOutFromRightAnimation.setInterpolator(interpolator);
  mPullOutFromRightAnimation.setDuration(ANIMATION_DURATION);
}
 
Example 4
Source File: BottomViewHideShowAnimation.java    From ExoMedia with Apache License 2.0 5 votes vote down vote up
public BottomViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);


    //Creates the Translate animation for the transition
    int startY = toVisible ? getHideShowDelta(view) : 0;
    int endY = toVisible ? 0 : getHideShowDelta(view);
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, startY, endY);
    translateAnimation.setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);


    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}
 
Example 5
Source File: DynamicDetailFragment.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a(ViewGroup viewgroup, ViewGroup viewgroup1)
{
    viewgroup.setVisibility(4);
    viewgroup1.setVisibility(0);
    AnimationSet animationset = new AnimationSet(true);
    AlphaAnimation alphaanimation = new AlphaAnimation(0.0F, 1.0F);
    alphaanimation.setDuration(80L);
    animationset.addAnimation(alphaanimation);
    TranslateAnimation translateanimation = new TranslateAnimation(1, 0.0F, 1, 0.0F, 1, -1F, 1, 0.0F);
    translateanimation.setDuration(100L);
    translateanimation.setInterpolator(new DecelerateInterpolator());
    animationset.addAnimation(translateanimation);
    viewgroup1.setLayoutAnimation(new LayoutAnimationController(animationset, 0.7F));
    viewgroup1.requestLayout();
}
 
Example 6
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 7
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 8
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 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: AnimationController.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
public void slideFadeOutToTop(View view, long durationMillis, long delayMillis)
{
	TranslateAnimation animation1 = new TranslateAnimation(rela1, 0, rela1, 0, rela1, 0, rela1, -1);
	AlphaAnimation animation2 = new AlphaAnimation(1, 0);
	AnimationSet animation = new AnimationSet(false);
	animation.addAnimation(animation1);
	animation.addAnimation(animation2);
	animation1.setInterpolator(new LinearInterpolator());
	baseOut(view, animation, durationMillis, delayMillis);
}
 
Example 11
Source File: SlideInMenuPage.java    From Paginize with MIT License 5 votes vote down vote up
@Override
public boolean onPopPageAnimation(View oldPageView, View newPageView, AnimationDirection animationDirection) {
  TranslateAnimation anim = new TranslateAnimation(
      Animation.ABSOLUTE, 0,
      Animation.ABSOLUTE, 0,
      Animation.RELATIVE_TO_PARENT, 0,
      Animation.RELATIVE_TO_PARENT, 1);
  anim.setDuration(getAnimationDuration());
  anim.setInterpolator(new DecelerateInterpolator(1.5f));
  mMenuItemContainer.startAnimation(anim);

  mViewSemiTransparentBackground.animate().alpha(0).setDuration(getAnimationDuration()).start();
  return true;
}
 
Example 12
Source File: RightViewHideShowAnimation.java    From v9porn with MIT License 5 votes vote down vote up
public RightViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);


    //Creates the Translate animation for the transition
    int startX = toVisible ? getHideShowDelta(view) : 0;
    int endX = toVisible ? 0 : getHideShowDelta(view);
    TranslateAnimation translateAnimation = new TranslateAnimation(startX, endX, 0, 0);
    translateAnimation.setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);


    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}
 
Example 13
Source File: ViewUtils.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
public static void showViewFromBottom(View view) {
    if (view.getVisibility() == View.VISIBLE) {
        return;
    }
    view.setVisibility(View.VISIBLE);
    int height = view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0);
    translateAnimation.setDuration(ANIMATION_DURATION);
    translateAnimation.setInterpolator(sAnimationInterpolator);
    view.startAnimation(translateAnimation);
}
 
Example 14
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 15
Source File: RightViewHideShowAnimation.java    From v9porn with MIT License 5 votes vote down vote up
public RightViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);


    //Creates the Translate animation for the transition
    int startX = toVisible ? getHideShowDelta(view) : 0;
    int endX = toVisible ? 0 : getHideShowDelta(view);
    TranslateAnimation translateAnimation = new TranslateAnimation(startX, endX, 0, 0);
    translateAnimation.setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);


    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}
 
Example 16
Source File: GameActivity.java    From SchoolQuest with GNU General Public License v3.0 5 votes vote down vote up
private void setUpTextBoxArrowAnimation() {
    ImageView textBoxArrow = findViewById(R.id.textbox_box_arrow);
    TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.01f);
    textBoxArrowAnimation.setDuration(500);
    textBoxArrowAnimation.setRepeatCount(-1);
    textBoxArrowAnimation.setRepeatMode(Animation.RESTART);
    textBoxArrowAnimation.setInterpolator(new LinearInterpolator());
    textBoxArrowAnimation.setFillAfter(true);

    textBoxArrow.setAnimation(textBoxArrowAnimation);
}
 
Example 17
Source File: MainActivity.java    From sealtalk-android with MIT License 4 votes vote down vote up
private void selectNavSelection(int index) {
    clearSelection();
    switch (index) {
        case 0:
            mMainConversationTv.setTextColor(getResources().getColor(R.color.de_title_bg));
            TranslateAnimation animation = new TranslateAnimation(0, 0,
                    0f, 0f);
            animation.setInterpolator(new LinearInterpolator());
            animation.setDuration(100);
            animation.setFillAfter(true);
            mMainSelectImg.startAnimation(animation);

            break;
        case 1:
            mMainGroupTv.setTextColor(getResources().getColor(R.color.de_title_bg));
            TranslateAnimation animation1 = new TranslateAnimation(
                    indicatorWidth, indicatorWidth,
                    0f, 0f);
            animation1.setInterpolator(new LinearInterpolator());
            animation1.setDuration(100);
            animation1.setFillAfter(true);
            mMainSelectImg.startAnimation(animation1);

            break;
        case 2:
            mMainChatroomTv.setTextColor(getResources().getColor(R.color.de_title_bg));
            TranslateAnimation animation2 = new TranslateAnimation(
                    2 * indicatorWidth, indicatorWidth * 2,
                    0f, 0f);
            animation2.setInterpolator(new LinearInterpolator());
            animation2.setDuration(100);
            animation2.setFillAfter(true);
            mMainSelectImg.startAnimation(animation2);

            break;
        case 3:
            mMainCustomerTv.setTextColor(getResources().getColor(R.color.de_title_bg));
            TranslateAnimation animation3 = new TranslateAnimation(
                    3 * indicatorWidth, indicatorWidth * 3,
                    0f, 0f);
            animation3.setInterpolator(new LinearInterpolator());
            animation3.setDuration(100);
            animation3.setFillAfter(true);
            mMainSelectImg.startAnimation(animation3);
            break;
    }
}
 
Example 18
Source File: QrCodeScanActivity.java    From FamilyChat with Apache License 2.0 4 votes vote down vote up
protected void initUI()
{
    //全屏设置
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        View statusBar = findViewById(R.id.view_qrcode_actionbar_status);
        statusBar.setVisibility(View.VISIBLE);
        ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
        layoutParams.height = OtherUtils.getStatusBarHeight(this);
        statusBar.setLayoutParams(layoutParams);
    }

    //闪光灯
    mImgLight = (ImageView) findViewById(R.id.img_qrcode_light);

    mScanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    mScanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    mScanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    mScanLine = (ImageView) findViewById(R.id.capture_scan_line);
    //设置阴影
    View shadowTop = findViewById(R.id.capture_mask_top);
    View shadowBottom = findViewById(R.id.capture_mask_bottom);
    View shadowLeft = findViewById(R.id.capture_mask_left);
    View shadowRight = findViewById(R.id.capture_mask_right);
    shadowTop.setAlpha(0.5f);
    shadowBottom.setAlpha(0.5f);
    shadowLeft.setAlpha(0.5f);
    shadowRight.setAlpha(0.5f);

    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = 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.85f);
    animation.setDuration(2500);
    animation.setRepeatCount(-1);
    animation.setInterpolator(new AccelerateDecelerateInterpolator(QrCodeScanActivity.this, null));
    animation.setRepeatMode(Animation.RESTART);
    mScanLine.startAnimation(animation);

    findViewById(R.id.ll_qrcode_actionbar_left_back).setOnClickListener(this);
    mImgLight.setOnClickListener(this);
}
 
Example 19
Source File: AutoEditText.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
public static TranslateAnimation getShakeAnimation(int count) {
        TranslateAnimation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
        translateAnimation.setInterpolator(new CycleInterpolator(count));
        translateAnimation.setDuration(1000);
        return translateAnimation;
}
 
Example 20
Source File: AnimateFactory.java    From TvWidget with Apache License 2.0 4 votes vote down vote up
public static Animation shakeAnimate() {
    TranslateAnimation mAnimate = new TranslateAnimation(0, 5, 0, 0);
    mAnimate.setInterpolator(new CycleInterpolator(50));
    mAnimate.setDuration(600);
    return mAnimate;
}