android.view.View.animate()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(396)

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

View.animate介绍

暂无

代码示例

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

private void addAnimate(SmartViewHolder holder, int postion) {
  if (mOpenAnimationEnable && mLastPosition < postion) {
    holder.itemView.setAlpha(0);
    holder.itemView.animate().alpha(1).start();
    mLastPosition = postion;
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

ViewPropertyAnimatorICS(View view) {
  mNative = new WeakReference<android.view.ViewPropertyAnimator>(view.animate());
}

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

@Override
public void onStartAnimator(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
  final View progressView = mProgressView;
  if (progressView.getVisibility() != VISIBLE) {
    progressView.setVisibility(VISIBLE);
    Drawable drawable = mProgressView.getDrawable();
    if (drawable instanceof Animatable) {
      ((Animatable) drawable).start();
    } else {
      progressView.animate().rotation(36000).setDuration(100000);
    }
  }
}

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

@Override
public void onReleased(@NonNull final RefreshLayout layout, int height, int maxDragHeight) {
  final View imageView = mImageView;
  final View dropView = mWaterDropView;
  mProgressDrawable.start();
  imageView.setVisibility(GONE);
  mWaterDropView.createAnimator().start();//开始回弹
  dropView.animate().setDuration(150).alpha(0).setListener(new AnimatorListenerAdapter() {
    public void onAnimationEnd(Animator animation) {
      dropView.setVisibility(GONE);
      dropView.setAlpha(1);
    }
  });
}

代码示例来源:origin: h6ah4i/android-advancedrecyclerview

@TargetApi(Build.VERSION_CODES.KITKAT)
  public static void clearViewPropertyAnimatorUpdateListener(View view) {
    view.animate().setUpdateListener(null);
  }
}

代码示例来源:origin: stackoverflow.com

float dX, dY;

@Override
public boolean onTouch(View view, MotionEvent event) {

  switch (event.getAction()) {

    case MotionEvent.ACTION_DOWN:

      dX = view.getX() - event.getRawX();
      dY = view.getY() - event.getRawY();
      break;

    case MotionEvent.ACTION_MOVE:

      view.animate()
          .x(event.getRawX() + dX)
          .y(event.getRawY() + dY)
          .setDuration(0)
          .start();
      break;
    default:
      return false;
  }
  return true;
}

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

@Override
  public boolean onTwoLevel(@NonNull RefreshLayout refreshLayout) {
    Toast.makeText(getContext(),"触发二楼事件",Toast.LENGTH_SHORT).show();
    root.findViewById(R.id.secondfloor_content).animate().alpha(1).setDuration(2000);
    refreshLayout.getLayout().postDelayed(new Runnable() {
      @Override
      public void run() {
        header.finishTwoLevel();
        root.findViewById(R.id.secondfloor_content).animate().alpha(0).setDuration(1000);
      }
    },5000);
    return true;//true 将会展开二楼状态 false 关闭刷新
  }
});

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

@Override
public int onFinish(@NonNull RefreshLayout refreshLayout, boolean success) {
  final View progressView = mProgressView;
  Drawable drawable = mProgressView.getDrawable();
  if (drawable instanceof Animatable) {
    if (((Animatable) drawable).isRunning()) {
      ((Animatable) drawable).stop();
    }
  } else {
    progressView.animate().rotation(0).setDuration(0);
  }
  progressView.setVisibility(GONE);
  return mFinishDuration;//延迟500毫秒之后再弹回
}

代码示例来源:origin: arimorty/floatingsearchview

private void animateItem(View view) {
    view.setTranslationY(Util.getScreenHeight((Activity) view.getContext()));
    view.animate()
        .translationY(0)
        .setInterpolator(new DecelerateInterpolator(3.f))
        .setDuration(700)
        .start();
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

private void animateUserProfileHeader() {
      vUserProfileRoot.setTranslationY(-vUserProfileRoot.getHeight());
      ivUserProfilePhoto.setTranslationY(-ivUserProfilePhoto.getHeight());
      vUserDetails.setTranslationY(-vUserDetails.getHeight());
      vUserStats.setAlpha(0);

      vUserProfileRoot.animate().translationY(0).setDuration(300).setInterpolator(INTERPOLATOR);
      ivUserProfilePhoto.animate().translationY(0).setDuration(300).setStartDelay(100).setInterpolator(INTERPOLATOR);
      vUserDetails.animate().translationY(0).setDuration(300).setStartDelay(200).setInterpolator(INTERPOLATOR);
      vUserStats.animate().alpha(1).setDuration(200).setStartDelay(400).setInterpolator(INTERPOLATOR).start();
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void translateWidgets(int deltaX, View... views) {
 for (final View v : views) {
  v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
  v.animate().translationXBy(deltaX).setDuration(ANIM_DURATION)
   .setListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
     v.setLayerType(View.LAYER_TYPE_NONE, null);
    }
   });
 }
}

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

@Override
public int onFinish(@NonNull RefreshLayout layout, boolean success) {
  final View circleView = mCircleView;
  mProgress.stop();
  circleView.animate().scaleX(0).scaleY(0);
  mFinished = true;
  return 0;
}

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

@Override
protected void onDetachedFromWindow() {
  super.onDetachedFromWindow();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    final View arrowView = mArrowView;
    final View progressView = mProgressView;
    arrowView.animate().cancel();
    progressView.animate().cancel();
  }
  final Drawable drawable = mProgressView.getDrawable();
  if (drawable instanceof Animatable) {
    if (((Animatable) drawable).isRunning()) {
      ((Animatable) drawable).stop();
    }
  }
}

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

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int scrollRange = appBarLayout.getTotalScrollRange();
    float fraction = 1f * (scrollRange + verticalOffset) / scrollRange;
    if (fraction < 0.1 && misAppbarExpand) {
      misAppbarExpand = false;
      fab.animate().scaleX(0).scaleY(0);
    }
    if (fraction > 0.8 && !misAppbarExpand) {
      misAppbarExpand = true;
      fab.animate().scaleX(1).scaleY(1);
    }
  }
});

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

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int scrollRange = appBarLayout.getTotalScrollRange();
    float fraction = 1f * (scrollRange + verticalOffset) / scrollRange;
    if (fraction < 0.1 && misAppbarExpand) {
      misAppbarExpand = false;
      fab.animate().scaleX(0).scaleY(0);
    }
    if (fraction > 0.8 && !misAppbarExpand) {
      misAppbarExpand = true;
      fab.animate().scaleX(1).scaleY(1);
    }
  }
});

代码示例来源:origin: h6ah4i/android-advancedrecyclerview

protected void resetAnimation(@NonNull RecyclerView.ViewHolder holder) {
  if (sDefaultInterpolator == null) {
    sDefaultInterpolator = new ValueAnimator().getInterpolator();
  }
  holder.itemView.animate().setInterpolator(sDefaultInterpolator);
  endAnimation(holder);
}

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

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int scrollRange = appBarLayout.getTotalScrollRange();
    float fraction = 1f * (scrollRange + verticalOffset) / scrollRange;
    if (fraction < 0.1 && misAppbarExpand) {
      misAppbarExpand = false;
      fab.animate().scaleX(0).scaleY(0);
    }
    if (fraction > 0.8 && !misAppbarExpand) {
      misAppbarExpand = true;
      fab.animate().scaleX(1).scaleY(1);
    }
  }
});

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

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int scrollRange = appBarLayout.getTotalScrollRange();
    float fraction = 1f * (scrollRange + verticalOffset) / scrollRange;
    if (fraction < 0.1 && misAppbarExpand) {
      misAppbarExpand = false;
      fab.animate().scaleX(0).scaleY(0);
    }
    if (fraction > 0.8 && !misAppbarExpand) {
      misAppbarExpand = true;
      fab.animate().scaleX(1).scaleY(1);
    }
  }
});

代码示例来源:origin: seven332/EhViewer

private void hideActionFab() {
  if (null != mFabLayout && STATE_NORMAL == mState && mShowActionFab) {
    mShowActionFab = false;
    View fab = mFabLayout.getPrimaryFab();
    fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener)
        .setDuration(ANIMATE_TIME).setStartDelay(0L)
        .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start();
  }
}

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

@Override
public void endAnimation(RecyclerView.ViewHolder holder) {
  holder.itemView.animate().cancel();
  if (pendingAdds.remove(holder)) {
    dispatchAddFinished(holder);
    clearAnimatedValues(holder.itemView);
  }
  super.endAnimation(holder);
}

相关文章

微信公众号

最新文章

更多

View类方法