android.animation.ObjectAnimator类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(164)

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

ObjectAnimator介绍

暂无

代码示例

代码示例来源:origin: florent37/ExpectAnim

public void reset() {
  final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "percent", 1f, 0f);
  objectAnimator.setDuration(duration);
  if (interpolator != null) {
    objectAnimator.setInterpolator(interpolator);
  }
  objectAnimator.start();
}

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

private void hideSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mHideSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.hide();
    mShowSystemUi = false;
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

public void doEndAnim() {
    mAnimator = ObjectAnimator.ofInt(this, "InnViewPositionX", mInnViewPositionX, mInnCenterPositionX);
    mAnimator.setDuration(250);
    mAnimator.start();
  }
}

代码示例来源:origin: PhilJay/MPAndroidChart

public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) {
  super(viewPortHandler, xValue, yValue, trans, v);
  this.xOrigin = xOrigin;
  this.yOrigin = yOrigin;
  animator = ObjectAnimator.ofFloat(this, "phase", 0f, 1f);
  animator.setDuration(duration);
  animator.addUpdateListener(this);
  animator.addListener(this);
}

代码示例来源:origin: PhilJay/MPAndroidChart

protected void resetAnimator(){
  animator.removeAllListeners();
  animator.removeAllUpdateListeners();
  animator.reverse();
  animator.addUpdateListener(this);
  animator.addListener(this);
}

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

ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 500); // see this max value coming back here, we animale towards that value
animation.setDuration (5000); //in milliseconds
animation.setInterpolator (new DecelerateInterpolator ());
animation.start ();

代码示例来源: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: scwang90/SmartRefreshLayout

if (mFlyAnimator != null) {
  mFlyAnimator.end();
  mFlyView.clearAnimation();
final int offDistX = ((View) mRefreshLayout).getWidth()-mFlyView.getLeft();
final int offDistY = -(mFlyView.getTop() - mOffset) * 2 / 3;
ObjectAnimator transX = ObjectAnimator.ofFloat(mFlyView, "translationX", 0, offDistX);
ObjectAnimator transY = ObjectAnimator.ofFloat(mFlyView, "translationY", 0, offDistY);
transY.setInterpolator(PathInterpolatorCompat.create(0.7f, 1f));
ObjectAnimator rotation = ObjectAnimator.ofFloat(mFlyView, "rotation", mFlyView.getRotation(), 0);
rotation.setInterpolator(new DecelerateInterpolator());
ObjectAnimator rotationX = ObjectAnimator.ofFloat(mFlyView, "rotationX", mFlyView.getRotationX(), 50);
rotationX.setInterpolator(new DecelerateInterpolator());
    ,rotation
    ,rotationX
    ,ObjectAnimator.ofFloat(mFlyView, "scaleX", mFlyView.getScaleX(), 0.5f)
    ,ObjectAnimator.ofFloat(mFlyView, "scaleY", mFlyView.getScaleY(), 0.5f)
);

代码示例来源:origin: aa112901/remusic

public void initRotateAnimation(float start) {
  mObjectAnimator = ObjectAnimator.ofFloat(this, "rotation", start, 360f + start);
  mObjectAnimator.setDuration(DEFAULT_DURATION);
  mObjectAnimator.setInterpolator(new LinearInterpolator());
  mObjectAnimator.setRepeatCount(ObjectAnimator.INFINITE);
}

代码示例来源:origin: sunfusheng/StickyHeaderListView

public void hide() {
  isShowing = false;
  resetViewStatus();
  rotateArrowDown(filterPosition);
  rotateArrowDown(lastFilterPosition);
  filterPosition = -1;
  lastFilterPosition = -1;
  viewMaskBg.setVisibility(View.GONE);
  ObjectAnimator.ofFloat(llContentListView, "translationY", 0, -panelHeight).setDuration(200).start();
}

代码示例来源:origin: aa112901/remusic

mRotateAnim = (ObjectAnimator) mActiveView.getTag(R.id.tag_animator);
mProgress.postDelayed(mUpdateProgress, 200);
mControl.setImageResource(R.drawable.play_rdi_btn_pause);
if (mAnimatorSet != null && mRotateAnim != null && !mRotateAnim.isRunning()) {
    mNeedleAnim = ObjectAnimator.ofFloat(mNeedle, "rotation", -30, 0);
    mNeedleAnim.setDuration(200);
    mNeedleAnim.setRepeatMode(0);
    mNeedleAnim.setInterpolator(new LinearInterpolator());
mControl.setImageResource(R.drawable.play_rdi_btn_play);
if (mNeedleAnim != null) {
  mNeedleAnim.reverse();
  mNeedleAnim.end();
if (mRotateAnim != null && mRotateAnim.isRunning()) {
  mRotateAnim.cancel();
  float valueAvatar = (float) mRotateAnim.getAnimatedValue();
  mRotateAnim.setFloatValues(valueAvatar, 360f + valueAvatar);

代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout

/**
 * 开启转圈圈
 *
 * @param v
 */
public void startSunLineAnim(View v) {
  if (mAnimator == null) {
    mAnimator = ObjectAnimator.ofFloat(v, "rotation", 0f, 720f);
    mAnimator.setDuration(7 * 1000);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.setRepeatCount(ValueAnimator.INFINITE);
  }
  if (!mAnimator.isRunning())
    mAnimator.start();
}

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

if(event.getX()<handle.getX())
   return false;
  if(currentAnimator!=null)
   currentAnimator.cancel();
  if(bubble.getVisibility()==INVISIBLE)
   showBubble();
  handle.setSelected(true);
 case MotionEvent.ACTION_MOVE:
  setPosition(event.getY());
 case MotionEvent.ACTION_UP:
 case MotionEvent.ACTION_CANCEL:
  handle.setSelected(false);
  hideBubble();
  return true;
AnimatorSet animatorSet=new AnimatorSet();
bubble.setVisibility(VISIBLE);
if(currentAnimator!=null)
 currentAnimator.cancel();
currentAnimator=ObjectAnimator.ofFloat(bubble,"alpha",0f,1f).setDuration(BUBBLE_ANIMATION_DURATION);
currentAnimator.start();
 currentAnimator.cancel();
currentAnimator=ObjectAnimator.ofFloat(bubble,"alpha",1f,0f).setDuration(BUBBLE_ANIMATION_DURATION);
currentAnimator.addListener(new AnimatorListenerAdapter()
currentAnimator.start();

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

final int offDistX = -mFlyView.getRight();
final int offDistY = -DensityUtil.dp2px(10);
AnimatorSet flyDownAnim = new AnimatorSet();
flyDownAnim.setDuration(800);
ObjectAnimator transX1 = ObjectAnimator.ofFloat(mFlyView, "translationX", mFlyView.getTranslationX(), offDistX);
ObjectAnimator transY1 = ObjectAnimator.ofFloat(mFlyView, "translationY", mFlyView.getTranslationY(), offDistY);
transY1.setInterpolator(PathInterpolatorCompat.create(0.1f, 1f));
ObjectAnimator rotation1 = ObjectAnimator.ofFloat(mFlyView, "rotation", mFlyView.getRotation(), 0);
ObjectAnimator rotationX1 = ObjectAnimator.ofFloat(mFlyView, "rotationX", mFlyView.getRotationX(), 30);
rotation1.setInterpolator(new AccelerateInterpolator());
flyDownAnim.playTogether(transX1, transY1
    , rotation1
    , rotationX1
    , ObjectAnimator.ofFloat(mFlyView, "scaleX", mFlyView.getScaleX(), 0.9f)
    , ObjectAnimator.ofFloat(mFlyView, "scaleY", mFlyView.getScaleY(), 0.9f)
);
flyDownAnim.addListener(new AnimatorListenerAdapter() {
AnimatorSet flyInAnim = new AnimatorSet();
flyInAnim.setDuration(800);
flyInAnim.setInterpolator(new DecelerateInterpolator());
ObjectAnimator tranX2 = ObjectAnimator.ofFloat(mFlyView, "translationX", offDistX, 0);
ObjectAnimator tranY2 = ObjectAnimator.ofFloat(mFlyView, "translationY", offDistY, 0);
ObjectAnimator rotationX2 = ObjectAnimator.ofFloat(mFlyView, "rotationX", 30, 0);
flyInAnim.playTogether(tranX2, tranY2
    , rotationX2
    , ObjectAnimator.ofFloat(mFlyView, "scaleX", 0.9f, 1f)
    , ObjectAnimator.ofFloat(mFlyView, "scaleY", 0.9f, 1f)
);

代码示例来源:origin: balysv/material-ripple

private void startHover() {
  if (eventCancelled) return;
  if (hoverAnimator != null) {
    hoverAnimator.cancel();
  }
  final float radius = (float) (Math.sqrt(Math.pow(getWidth(), 2) + Math.pow(getHeight(), 2)) * 1.2f);
  hoverAnimator = ObjectAnimator.ofFloat(this, radiusProperty, rippleDiameter, radius)
    .setDuration(HOVER_DURATION);
  hoverAnimator.setInterpolator(new LinearInterpolator());
  hoverAnimator.start();
}

代码示例来源:origin: Ramotion/paper-onboarding-android

protected Animator createContentCenteringVerticalAnimation(View newContentText, View newContentIcon) {
  newContentText.measure(View.MeasureSpec.makeMeasureSpec(mContentCenteredContainer.getWidth(), View.MeasureSpec.AT_MOST), -2);
  int measuredContentTextHeight = newContentText.getMeasuredHeight();
  newContentIcon.measure(-2, -2);
  int measuredContentIconHeight = newContentIcon.getMeasuredHeight();
  int newHeightOfContent = measuredContentIconHeight + measuredContentTextHeight + ((ViewGroup.MarginLayoutParams) mContentTextContainer.getLayoutParams()).topMargin;
  Animator centerContentAnimation = ObjectAnimator.ofFloat(mContentCenteredContainer, "y", mContentCenteredContainer.getY(),
      (mContentRootLayout.getHeight() - newHeightOfContent) / 2);
  centerContentAnimation.setDuration(ANIM_CONTENT_CENTERING_TIME);
  centerContentAnimation.setInterpolator(new DecelerateInterpolator());
  return centerContentAnimation;
}

代码示例来源:origin: wasabeef/recyclerview-animators

@Override protected Animator[] getAnimators(View view) {
  return new Animator[] {
    ObjectAnimator.ofFloat(view, "translationX", -view.getRootView().getWidth(), 0)
  };
 }
}

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

public void startFromLocation(int[] tapLocationOnScreen) {
  changeState(STATE_FILL_STARTED);
  startLocationX = tapLocationOnScreen[0];
  startLocationY = tapLocationOnScreen[1];
  revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME);
  revealAnimator.setInterpolator(INTERPOLATOR);
  revealAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_FINISHED);
    }
  });
  revealAnimator.start();
}

代码示例来源:origin: xfumihiro/ViewInspector

@SuppressWarnings("deprecation") public void closeToolbar() {
 closeMenu();
 ObjectAnimator animator =
   ObjectAnimator.ofFloat(mToolbar, "translationX", mToolbar.getTranslationX(), mToolbarWidth);
 animator.setInterpolator(new DecelerateInterpolator());
 animator.start();
 mToggleButton.setImageDrawable(
   getResources().getDrawable(R.drawable.ic_chevron_left_white_24dp));
}

代码示例来源:origin: aa112901/remusic

@Override
public void onClick(View v) {
  ObjectAnimator anim = null;
  anim = ObjectAnimator.ofFloat(sectionImg, "rotation", 90, 0);
  anim.setDuration(100);
  anim.setRepeatCount(0);
  anim.setInterpolator(new LinearInterpolator());
  switch (getItemViewType()) {
        updateResults(itemResults, playlists, netplaylists);
        notifyItemRangeRemoved(5, playlists.size());
        anim.start();
        updateResults(itemResults, playlists, netplaylists);
        notifyItemRangeInserted(5, playlists.size());
        anim.reverse();
        createdExpanded = true;
        int len = playlists.size();
        notifyItemRangeRemoved(6 + len, netplaylists.size());
        anim.start();
        int len = playlists.size();
        notifyItemRangeInserted(6 + len, netplaylists.size());
        anim.reverse();
        collectExpanded = true;

相关文章