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

The following examples show how to use android.view.animation.TranslateAnimation#setStartOffset() . 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: ActionSheetDialog.java    From AutoTest with MIT License 5 votes vote down vote up
private void init() {
    widthScale(0.95f);
    /** LayoutAnimation */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
            0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(350);
    animation.setStartOffset(150);

    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
 
Example 2
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从左侧进入,并带有弹性的动画
 *
 * @return
 */
public static AnimationSet getAnimationSetFromLeft() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, -1.0f, RELATIVE_TO_SELF, 0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(300);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    TranslateAnimation translateX2 = new TranslateAnimation(RELATIVE_TO_SELF, 0.1f, RELATIVE_TO_SELF, -0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX2.setStartOffset(300);
    translateX2.setInterpolator(new DecelerateInterpolator());
    translateX2.setDuration(50);

    TranslateAnimation translateX3 = new TranslateAnimation(RELATIVE_TO_SELF, -0.1f, RELATIVE_TO_SELF, 0f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX3.setStartOffset(350);
    translateX3.setInterpolator(new DecelerateInterpolator());
    translateX3.setDuration(50);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f);
    alphaAnimation.setDuration(400);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());


    animationSet.addAnimation(translateX1);
    animationSet.addAnimation(translateX2);
    animationSet.addAnimation(translateX3);
    //animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 3
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从右侧进入,并带有弹性的动画
 *
 * @return
 */
public static AnimationSet getAnimationSetFromRight() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, 1.0f, RELATIVE_TO_SELF, -0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(300);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    TranslateAnimation translateX2 = new TranslateAnimation(RELATIVE_TO_SELF, -0.1f, RELATIVE_TO_SELF, 0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX2.setStartOffset(300);
    translateX2.setInterpolator(new DecelerateInterpolator());
    translateX2.setDuration(50);

    TranslateAnimation translateX3 = new TranslateAnimation(RELATIVE_TO_SELF, 0.1f, RELATIVE_TO_SELF, 0f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX3.setStartOffset(350);
    translateX3.setInterpolator(new DecelerateInterpolator());
    translateX3.setDuration(50);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f);
    alphaAnimation.setDuration(400);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());


    animationSet.addAnimation(translateX1);
    animationSet.addAnimation(translateX2);
    animationSet.addAnimation(translateX3);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 4
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从底部进入
 *
 * @return
 */
public static AnimationSet getAnimationSetFromBottom() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0,
            RELATIVE_TO_SELF, 2.5f, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(400);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    animationSet.addAnimation(translateX1);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 5
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从顶部进入
 *
 * @return
 */
public static AnimationSet getAnimationSetFromTop() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0,
            RELATIVE_TO_SELF, -2.5f, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(400);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    animationSet.addAnimation(translateX1);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 6
Source File: AnimationUtil.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private static void ApplyHorizontalScrollAnimation(View view, boolean left, int speed) {
  float sign = left ? 1f : -1f;
  AnimationSet animationSet = new AnimationSet(true);
  animationSet.setRepeatCount(Animation.INFINITE);
  animationSet.setRepeatMode(Animation.RESTART);

  TranslateAnimation move = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, sign * 0.70f,
      Animation.RELATIVE_TO_PARENT, sign * -0.70f, Animation.RELATIVE_TO_PARENT, 0,
      Animation.RELATIVE_TO_PARENT, 0);
  move.setStartOffset(0);
  move.setDuration(speed);
  move.setFillAfter(true);
  animationSet.addAnimation(move);
  view.startAnimation(animationSet);
}
 
Example 7
Source File: ActionSheetDialog.java    From RecordVideo with Apache License 2.0 5 votes vote down vote up
private void init() {
    widthScale(0.95f);
    /** LayoutAnimation */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
            0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(350);
    animation.setStartOffset(150);

    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
 
Example 8
Source File: ActionSheetDialog.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void init() {
    widthScale(0.95f);
    /** LayoutAnimation */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
            0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(350);
    animation.setStartOffset(150);

    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
 
Example 9
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 10
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void startAnimation(){

        TranslateAnimation upUp = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,-1);
        upUp.setDuration(1000);
        TranslateAnimation upDown = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,1);
        upDown.setDuration(1000);
        upDown.setStartOffset(1000);

        //组合动画
        AnimationSet upSet = new AnimationSet(false);
        //将上面的动画添加到组合动画
        upSet.addAnimation(upUp);
        upSet.addAnimation(upDown);
        //控件开启动画
        iv_up.startAnimation(upSet);


        TranslateAnimation downDown = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,1);
        downDown.setDuration(1000);
        TranslateAnimation downUp = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,-1);
        downUp.setDuration(1000);
        downUp.setStartOffset(1000);

        AnimationSet downSet = new AnimationSet(false);
        downSet.addAnimation(downDown);
        downSet.addAnimation(downUp);

        iv_down.startAnimation(downSet);





    }
 
Example 11
Source File: ActionSheetDialog.java    From FlycoDialog_Master with MIT License 5 votes vote down vote up
private void init() {
    widthScale(0.95f);
    /** LayoutAnimation */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
            0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(350);
    animation.setStartOffset(150);

    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
 
Example 12
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 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 13
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 14
Source File: MovieDetails.java    From moviedb-android with Apache License 2.0 5 votes vote down vote up
/**
 * Creates animation for the gallery and gallery, homePage and trailer 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);
}