android.animation.AnimatorSet.setDuration()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中android.animation.AnimatorSet.setDuration()方法的一些代码示例,展示了AnimatorSet.setDuration()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnimatorSet.setDuration()方法的具体详情如下:
包路径:android.animation.AnimatorSet
类名称:AnimatorSet
方法名:setDuration

AnimatorSet.setDuration介绍

暂无

代码示例

代码示例来源:origin: Clans/FloatingActionButton

/**
 * Sets whether open and close actions should be animated
 *
 * @param animated if <b>false</b> - menu items will appear/disappear instantly without any animation
 */
public void setAnimated(boolean animated) {
  mIsAnimated = animated;
  mOpenAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0);
  mCloseAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0);
}

代码示例来源:origin: Rukey7/MvpApp

/**
 * 心跳动画
 * @param view  视图
 * @param duration  时间
 */
public static void doHeartBeat(View view, int duration) {
  AnimatorSet set = new AnimatorSet();
  set.playTogether(
      ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 1.4f, 0.9f, 1.0f),
      ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.4f, 0.9f, 1.0f)
  );
  set.setDuration(duration);
  set.start();
}

代码示例来源:origin: Rukey7/MvpApp

/**
 * 执行从右滑入动画
 * @param view
 * @param startX
 * @param endX
 * @param duration
 */
public static void doSlideRightIn(View view, int startX, int endX, int duration) {
  ObjectAnimator translationX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
  ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0, 1);
  AnimatorSet set = new AnimatorSet();
  set.setDuration(duration);
  set.playTogether(translationX, alpha);
  set.start();
}

代码示例来源:origin: cymcsg/UltimateAndroid

private void nextAnimation() {
  AnimatorSet anim = new AnimatorSet();
  if (scale) {
    anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1.5f, 1f),
        ObjectAnimator.ofFloat(this, "scaleY", 1.5f, 1f));
  } else {
    anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1, 1.5f),
        ObjectAnimator.ofFloat(this, "scaleY", 1, 1.5f));
  }
  anim.setDuration(10987);
  anim.addListener(this);
  anim.start();
  scale = !scale;
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
  View target = holder.itemView;
  View icon = target.findViewById(R.id.icon);
  Animator swing = ObjectAnimator.ofFloat(icon, "rotationX", 45, 0);
  swing.setInterpolator(new OvershootInterpolator(5));
  View right = holder.itemView.findViewById(R.id.right);
  Animator rotateIn = ObjectAnimator.ofFloat(right, "rotationY", 90, 0);
  rotateIn.setInterpolator(new DecelerateInterpolator());
  AnimatorSet animator = new AnimatorSet();
  animator.setDuration(getAddDuration());
  animator.playTogether(swing, rotateIn);
  animator.start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void translate(InfoBean bean, ExposeView parent, View child) {
  set.playTogether(
      ObjectAnimator.ofFloat(child, "translationX", 0, -bean.translationX),
      ObjectAnimator.ofFloat(child, "translationY", 0, -bean.translationY),
      ObjectAnimator.ofFloat(child, "scaleX", 1,1/bean.scale),
      ObjectAnimator.ofFloat(child, "scaleY", 1,1/bean.scale)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration).start();
}

代码示例来源:origin: gzu-liyujiang/AndroidPicker

@Override
protected void showAfter() {
  View rootView = getRootView();
  AnimatorSet animatorSet = new AnimatorSet();
  ObjectAnimator alpha = ObjectAnimator.ofFloat(rootView, "alpha", 0, 1);
  ObjectAnimator translation = ObjectAnimator.ofFloat(rootView, "translationY", 300, 0);
  animatorSet.playTogether(alpha, translation);
  animatorSet.setDuration(1000);
  animatorSet.setInterpolator(new AccelerateInterpolator());
  animatorSet.start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void loadPlaceholder(InfoBean bean, ImageView placeholder) {
  AnimatorSet set = new AnimatorSet();
  set.playTogether(
      ObjectAnimator.ofFloat(placeholder, "scaleX", 1, 0),
      ObjectAnimator.ofFloat(placeholder, "scaleY", 1, 0)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration / 4 * 5).start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void loadPlaceholder(InfoBean bean, ImageView placeholder) {
  AnimatorSet set = new AnimatorSet();
  set.playTogether(
      ObjectAnimator.ofFloat(placeholder,"rotation",0,180),
      ObjectAnimator.ofFloat(placeholder, "scaleX", 1, 0),
      ObjectAnimator.ofFloat(placeholder, "scaleY", 1, 0)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration / 4 * 5).start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void translate(InfoBean bean, ExposeView parent, View child) {
  set.playTogether(
      ObjectAnimator.ofFloat(child, "scaleY", 1)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration).start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void loadPlaceholder(InfoBean bean, ImageView placeholder) {
  AnimatorSet set = new AnimatorSet();
  set.playTogether(
      ObjectAnimator.ofFloat(placeholder, "rotation", 0, 180),
      ObjectAnimator.ofFloat(placeholder, "scaleX", 1, 0),
      ObjectAnimator.ofFloat(placeholder, "scaleY", 1, 0)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration / 4 * 5).start();
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
public void loadPlaceholder(InfoBean bean, ImageView placeholder) {
  AnimatorSet set = new AnimatorSet();
  set.playTogether(
      ObjectAnimator.ofFloat(placeholder, "rotation", 0, 180),
      ObjectAnimator.ofFloat(placeholder, "scaleX", 1, 0),
      ObjectAnimator.ofFloat(placeholder, "scaleY", 1, 0)
  );
  set.setInterpolator(new AccelerateInterpolator());
  set.setDuration(showDuration / 4 * 5).start();
  //placeholder.setVisibility(View.GONE);
}

代码示例来源:origin: ImmortalZ/TransitionHelper

@Override
  public void loadPlaceholder(InfoBean bean, ImageView placeholder) {
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
        ObjectAnimator.ofFloat(placeholder, "rotation", 0, 180),
        ObjectAnimator.ofFloat(placeholder, "scaleX", 1, 0),
        ObjectAnimator.ofFloat(placeholder, "scaleY", 1, 0)
    );
    set.setInterpolator(new AccelerateInterpolator());
    set.setDuration(showDuration / 4 * 5).start();
  }
})

代码示例来源:origin: jeasonlzy/ImagePicker

private void enterAnimator() {
  ObjectAnimator alpha = ObjectAnimator.ofFloat(masker, "alpha", 0, 1);
  ObjectAnimator translationY = ObjectAnimator.ofFloat(listView, "translationY", listView.getHeight(), 0);
  AnimatorSet set = new AnimatorSet();
  set.setDuration(400);
  set.playTogether(alpha, translationY);
  set.setInterpolator(new AccelerateDecelerateInterpolator());
  set.start();
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

/**
 * 爱心的显示动画实现
 */
private AnimatorSet getEnterAnimtorSet(View target) {
  //爱心的3中动画组合 透明度 x,y轴的缩放
  ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.2f, 1f);
  ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.2f, 1f);
  ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.2f, 1f);
  //组合动画
  AnimatorSet set = new AnimatorSet();
  set.setDuration(500);
  set.setInterpolator(new LinearInterpolator());
  set.playTogether(alpha, scaleX, scaleY);
  set.setTarget(target);
  return set;
}

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

/**
 * Animates given View.
 *
 * @param view the View that should be animated.
 */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
  if (mAnimationStartMillis == -1) {
    mAnimationStartMillis = SystemClock.uptimeMillis();
  }
  ViewCompat.setAlpha(view, 0);
  AnimatorSet set = new AnimatorSet();
  set.playTogether(animators);
  set.setStartDelay(calculateAnimationDelay(position));
  set.setDuration(mAnimationDurationMillis);
  set.start();
  mAnimators.put(view.hashCode(), set);
}

代码示例来源:origin: lyft/scissors

private void animate(Interpolator interpolator, long duration, ValueAnimator first, ValueAnimator... animators) {
    animator = new AnimatorSet();
    animator.setDuration(duration);
    animator.setInterpolator(interpolator);
    animator.addListener(animatorListener);
    AnimatorSet.Builder builder = animator.play(first);
    for(ValueAnimator valueAnimator : animators) {
      builder.with(valueAnimator);
    }
    animator.start();
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

flyUpAnim.setDuration(800);
flyUpAnim.playTogether(transX
    ,transY

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
public void onStartAnimator(@NonNull RefreshLayout layout, int height, int maxDragHeight) {
  super.onStartAnimator(layout, height, maxDragHeight);
  final View topView = mMaskViewTop;
  final View shadowView = mShadowView;
  final View bottomView = mMaskViewBottom;
  final AnimatorSet animatorSet = new AnimatorSet();
  animatorSet.play(ObjectAnimator.ofFloat(topView, "translationY", topView.getTranslationY(), -mHalfHeaderHeight))
      .with(ObjectAnimator.ofFloat(bottomView, "translationY", bottomView.getTranslationY(), mHalfHeaderHeight))
      .with(ObjectAnimator.ofFloat(shadowView, "alpha", shadowView.getAlpha(), 0));
  animatorSet.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      topView.setVisibility(View.GONE);
      bottomView.setVisibility(View.GONE);
      shadowView.setVisibility(View.GONE);
      postStatus(FunGameView.STATUS_GAME_PLAY);
    }
  });
  animatorSet.setDuration(800);
  animatorSet.setStartDelay(200);
  animatorSet.start();
}

代码示例来源:origin: nickbutcher/plaid

transition.setDuration(getDuration());
transition.setInterpolator(interpolator);
return transition;

相关文章