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

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

源代码1 项目: AutoTest   文件: ActionSheetDialog.java
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());
}
 
/**
 * 从左侧进入,并带有弹性的动画
 *
 * @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;
}
 
/**
 * 从右侧进入,并带有弹性的动画
 *
 * @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;
}
 
/**
 * 从底部进入
 *
 * @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;
}
 
/**
 * 从顶部进入
 *
 * @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;
}
 
源代码6 项目: appinventor-extensions   文件: AnimationUtil.java
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);
}
 
源代码7 项目: RecordVideo   文件: ActionSheetDialog.java
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());
}
 
源代码8 项目: SprintNBA   文件: ActionSheetDialog.java
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());
}
 
源代码9 项目: 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);
}
 
源代码10 项目: Study_Android_Demo   文件: MainActivity.java
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);





    }
 
源代码11 项目: FlycoDialog_Master   文件: ActionSheetDialog.java
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());
}
 
源代码12 项目: moviedb-android   文件: TVDetails.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);
}
 
源代码13 项目: 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);
}
 
源代码14 项目: moviedb-android   文件: MovieDetails.java
/**
 * 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);
}