private Animator createHideItemAnimator(final View item) { final float dx = centerItem.getX() - item.getX(); final float dy = centerItem.getY() - item.getY(); Animator anim = ObjectAnimator.ofPropertyValuesHolder( item, AnimatorUtils.scaleX(1f, 0f), AnimatorUtils.scaleY(1f, 0f), AnimatorUtils.translationX(0f, dx), AnimatorUtils.translationY(0f, dy)); anim.setInterpolator(new DecelerateInterpolator()); anim.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); item.setTranslationX(0f); item.setTranslationY(0f); } }); anim.setDuration(50); return anim; }
// 初始化歌曲列表 private void initLocalMusicList() { // fileInfos = MediaUtil.getFileInfos(getApplicationContext()); //获取歌曲对象集合 setListAdpter(MediaUtil.getMusicMaps(fileInfos)); // 显示歌曲列表 music_siger_tv.setText(fileInfos.get(listPosition).getArtist()); music_name_tv.setText(fileInfos.get(listPosition).getTitle()); music_play_bt.setPressed(play_bt_press); music_play_bt.setChecked(play_bt_check); anim = ObjectAnimator.ofFloat(music_album_iv, "rotation", 0, 360); lin = new LinearInterpolator(); anim.setDuration(6000); anim.setRepeatCount(-1); anim.setRepeatMode(ObjectAnimator.RESTART); anim.setInterpolator(lin); // 匀速 PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 0f, 1f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 0, 1f); PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 0, 1f); animSongName = ObjectAnimator.ofPropertyValuesHolder(music_name_tv, pvhX, pvhY, pvhZ); // 渐现 animSongName.setDuration(1000); animSongName.setRepeatCount(0); animSongName.setRepeatMode(ObjectAnimator.RESTART); animSongSinger = ObjectAnimator.ofPropertyValuesHolder(music_siger_tv, pvhX, pvhY, pvhZ); // 渐现 animSongSinger.setDuration(1000); animSongSinger.setRepeatCount(0); animSongSinger.setRepeatMode(ObjectAnimator.RESTART); }
/** Return to initial state */ public void finish(int finishMode) { if (!mAttached) { return; } mTextHint.setVisibility(View.GONE); if (finishMode == FINISH_SLIDE_OUT) { PropertyValuesHolder slideX = PropertyValuesHolder.ofFloat( "translationX", new float[] {0.0f, mScreenshotView.getWidth()}); mSlideoutAnimator = ObjectAnimator.ofPropertyValuesHolder(mScreenshotView, slideX); mSlideoutAnimator.setInterpolator(new AccelerateInterpolator()); mSlideoutAnimator.setDuration(SLIDE_OUT_DURATION_MS); mSlideoutAnimator.addListener(this); mSlideoutAnimator.start(); } else { float currentScale = mScreenshotView.getScaleX(); float currentAlpha = mScreenshotView.getAlpha(); PropertyValuesHolder scaleUpX = PropertyValuesHolder.ofFloat("scaleX", new float[] {currentScale, 1.0f}); PropertyValuesHolder scaleUpY = PropertyValuesHolder.ofFloat("scaleY", new float[] {currentScale, 1.0f}); PropertyValuesHolder scaleUpAlpha = PropertyValuesHolder.ofFloat("alpha", new float[] {currentAlpha, 1.0f}); mScaleUpAnimator = ObjectAnimator.ofPropertyValuesHolder(mScreenshotView, scaleUpX, scaleUpY, scaleUpAlpha); mScaleUpAnimator.setInterpolator(new DecelerateInterpolator()); mScaleUpAnimator.setDuration(SCALE_UP_DURATION_MS); mScaleUpAnimator.addListener(this); mScaleUpAnimator.start(); } }
private void flip(final View v1, final View v2, final boolean scale, boolean reverse) { final int duration = 300; final int degree = reverse ? 90 : -90; final int degree2 = -degree; final ObjectAnimator a, b; if (!scale) { a = ObjectAnimator.ofFloat(v1, "rotationY", 0, degree); b = ObjectAnimator.ofFloat(v2, "rotationY", degree2, 0); } else { final float scaleX = 0.5f; final float scaleY = 0.5f; a = ObjectAnimator.ofPropertyValuesHolder( v1, PropertyValuesHolder.ofFloat("rotationY", 0, degree), PropertyValuesHolder.ofFloat("scaleX", 1, scaleX), PropertyValuesHolder.ofFloat("scaleY", 1, scaleY)); b = ObjectAnimator.ofPropertyValuesHolder( v2, PropertyValuesHolder.ofFloat("rotationY", degree2, 0), PropertyValuesHolder.ofFloat("scaleX", scaleX, 1), PropertyValuesHolder.ofFloat("scaleY", scaleY, 1)); } a.setInterpolator(new LinearInterpolator()); b.setInterpolator(new LinearInterpolator()); a.setDuration(duration); b.setDuration(duration); a.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { v1.setVisibility(View.GONE); v2.setVisibility(View.VISIBLE); if (scale) { // 恢复scale v1.setScaleX(1); v1.setScaleY(1); } } @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); v1.setVisibility(View.VISIBLE); v2.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.play(a).before(b); set.start(); }
private void init() { PropertyValuesHolder valueHolder_1 = PropertyValuesHolder.ofFloat("scaleX", 1f, 0.9f); PropertyValuesHolder valueHolder_2 = PropertyValuesHolder.ofFloat("scaleY", 1f, 0.9f); anim1 = ObjectAnimator.ofPropertyValuesHolder(this, valueHolder_1, valueHolder_2); anim1.setDuration(200); anim1.setInterpolator(new LinearInterpolator()); PropertyValuesHolder valueHolder_3 = PropertyValuesHolder.ofFloat("scaleX", 0.9f, 1f); PropertyValuesHolder valueHolder_4 = PropertyValuesHolder.ofFloat("scaleY", 0.9f, 1f); anim2 = ObjectAnimator.ofPropertyValuesHolder(this, valueHolder_3, valueHolder_4); anim2.setDuration(200); anim2.setInterpolator(new LinearInterpolator()); }
public void animateClosed() { if (!(getParent() instanceof DragLayer)) return; ObjectAnimator oa; if (mMode == PARTIAL_GROW) { PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); } else { DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", mIconRect.width()); PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", mIconRect.height()); PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", mIconRect.left); PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", mIconRect.top); oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y); oa.addUpdateListener( new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { requestLayout(); } }); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha); alphaOa.setDuration(mExpandDuration); alphaOa.setInterpolator(new DecelerateInterpolator(2.0f)); alphaOa.start(); } oa.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCloseComplete(); mState = STATE_SMALL; } @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent( AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed)); mState = STATE_ANIMATING; } }); oa.setDuration(mExpandDuration); oa.start(); }
void animatePagesToCarousel() { if (mChildrenTransformsAnimator != null) { mChildrenTransformsAnimator.cancel(); mChildrenTransformsAnimator = null; } int count = getChildCount(); PropertyValuesHolder alpha; PropertyValuesHolder outlineAlpha; PropertyValuesHolder rotationY; PropertyValuesHolder pivotX; PropertyValuesHolder pivotY; ArrayList<Animator> anims = new ArrayList<Animator>(); for (int i = 0; i < count; i++) { KeyguardWidgetFrame child = getWidgetPageAt(i); float finalAlpha = getAlphaForPage(mScreenCenter, i, true); float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true); getTransformForPage(mScreenCenter, i, mTmpTransform); boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1); ObjectAnimator a; alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalAlpha); outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", finalOutlineAlpha); pivotX = PropertyValuesHolder.ofFloat("pivotX", mTmpTransform[0]); pivotY = PropertyValuesHolder.ofFloat("pivotY", mTmpTransform[1]); rotationY = PropertyValuesHolder.ofFloat("rotationY", mTmpTransform[2]); if (inVisibleRange) { // for the central pages we animate into a rotated state a = ObjectAnimator.ofPropertyValuesHolder( child, alpha, outlineAlpha, pivotX, pivotY, rotationY); } else { a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha); a.setInterpolator(mFastFadeInterpolator); } anims.add(a); } int duration = REORDERING_ZOOM_IN_OUT_DURATION; mChildrenTransformsAnimator = new AnimatorSet(); mChildrenTransformsAnimator.playTogether(anims); mChildrenTransformsAnimator.setDuration(duration); mChildrenTransformsAnimator.start(); }
private void showPostVoteAnimation(Vote vote) { if (vote == null || vote == Vote.NEUTRAL) return; // quickly center the vote button simulateScroll(); String text = vote == Vote.UP ? "+" : (vote == Vote.DOWN ? "-" : "*"); voteAnimationIndicator.setText(text); voteAnimationIndicator.setVisibility(View.VISIBLE); voteAnimationIndicator.setAlpha(0); voteAnimationIndicator.setScaleX(0.7f); voteAnimationIndicator.setScaleY(0.7f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( voteAnimationIndicator, ofFloat(View.ALPHA, 0, 0.6f, 0.7f, 0.6f, 0), ofFloat(View.SCALE_X, 0.7f, 1.3f), ofFloat(View.SCALE_Y, 0.7f, 1.3f)); animator.start(); animator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { View view = PostFragment.this.voteAnimationIndicator; if (view != null) { view.setVisibility(View.GONE); } } }); }
public void a() { hph localhph = a; ObjectAnimator localObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(this, new PropertyValuesHolder[] { PropertyValuesHolder.ofFloat("alpha", new float[] { 0.0F, 1.0F }), PropertyValuesHolder.ofFloat("translationY", new float[] { getHeight(), 0.0F }) }); localObjectAnimator.addListener(new hpr(this)); localhph.a(localObjectAnimator); }
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
public void propertyValuesHolder(View view) { Log.i("tag", "动画已经被执行"); PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 1f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 1f); PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 1f); Animator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(view, pvhX, pvhY, pvhZ).setDuration(2000); objectAnimator.start(); objectAnimator.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { if (mFirst) { turn2Activity(New_login.this, WelcomeActivity.class); } else { turn2Activity(New_login.this, NewMain.class); overridePendingTransition(R.anim.push_center_in, R.anim.push_center_out); } finish(); } @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); }
// 开始动画 private void startAnim() { // 遍历第一个不是主菜单的ImageView列表 for (int i = 1; i < res.length; i++) { // 获取展开角度 float angle = (90 * 1.0f / (res.length - 2)) * (i - 1); // 获取X位移 PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat( "translationX", 0, (float) (Math.sin((angle * 1.57 / 90)) * 200)); // 获取Y位移 PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat( "translationY", 0, (float) (Math.cos((angle * 1.57 / 90)) * 200)); // 设置ImageView的属性动画 ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageViewList.get(i), holder1, holder2); // ObjectAnimator animator = // ObjectAnimator.ofFloat(imageViewList.get(i), "translationY", 0, i * // 60); // 动画时间 animator.setDuration(1000); // 动画延迟时间 animator.setFrameDelay(500 * i); // 设置加速器 animator.setInterpolator(new BounceInterpolator()); // 启动动画 animator.start(); isNotExpand = false; } }
public void treeMe(final View view, boolean isUp) { ObjectAnimator.ofPropertyValuesHolder( view, PropertyValuesHolder.ofFloat(View.TRANSLATION_X, 40), PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, isUp ? 40 : -40)) .start(); }
/** Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn) .setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
private void startAnim(View convertView) { convertView.setPivotX(0.0f); convertView.setPivotY(1.0f); PropertyValuesHolder x = PropertyValuesHolder.ofFloat("scaleX", 0.0f, 1.0f); PropertyValuesHolder y = PropertyValuesHolder.ofFloat("scaleY", 0.0f, 1.0f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(convertView, x, y); animator.setDuration(animTime); animator.start(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override public ObjectAnimator getInitalAnimator(Context context) { ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( new Object(), PropertyValuesHolder.ofFloat("alpha", 0.5f, 1.f), PropertyValuesHolder.ofFloat("rotation", 60.f, 0.f)); animator.setDuration((long) (200 * mSpeedFactor)); return animator; }
@Override public void animateMenuOpening(Point center) { super.animateMenuOpening(center); setAnimating(true); Animator lastAnimation = null; for (int i = 0; i < menu.getSubActionItems().size(); i++) { menu.getSubActionItems().get(i).view.setScaleX(0); menu.getSubActionItems().get(i).view.setScaleY(0); menu.getSubActionItems().get(i).view.setAlpha(0); PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat( View.TRANSLATION_X, menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat( View.TRANSLATION_Y, menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2); PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 720); PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1); final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder( menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA); animation.setDuration(DURATION); animation.setInterpolator(new OvershootInterpolator(0.9f)); animation.addListener( new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING)); if (i == 0) { lastAnimation = animation; } // Put a slight lag between each of the menu items to make it asymmetric animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS); animation.start(); } if (lastAnimation != null) { lastAnimation.addListener(new LastAnimationListener()); } }
@Override public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); PropertyValuesHolder rotation5 = PropertyValuesHolder.ofFloat("rotationX", 0, 180, 180, 0, 0); PropertyValuesHolder rotation6 = PropertyValuesHolder.ofFloat("rotationY", 0, 0, 180, 180, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6, rotation5); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(-1); animator.setDuration(2500); animator.start(); animators.add(animator); return animators; }
public static ObjectAnimator tada(View view, float shakeFactor) { PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe( View.SCALE_X, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe( View.SCALE_Y, Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f)); PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe( View.ROTATION, Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor), Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate) .setDuration(1000); }
/** * This method takes some view and the values by which its top and bottom bounds should be changed * by. Given these params, an animation which will animate these bound changes is created and * returned. */ private Animator getAnimation(final View view, float translateTop, float translateBottom) { int top = view.getTop(); int bottom = view.getBottom(); int endTop = (int) (top + translateTop); int endBottom = (int) (bottom + translateBottom); PropertyValuesHolder translationTop = PropertyValuesHolder.ofInt("top", top, endTop); PropertyValuesHolder translationBottom = PropertyValuesHolder.ofInt("bottom", bottom, endBottom); return ObjectAnimator.ofPropertyValuesHolder(view, translationTop, translationBottom); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public ObjectAnimator getDisappearingAnimator(Context context) { ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( new Object(), PropertyValuesHolder.ofFloat("alpha", 1.f, 0.f), PropertyValuesHolder.ofFloat("scaleX", 1.f, 0.f), PropertyValuesHolder.ofFloat("scaleY", 1.f, 0.f), PropertyValuesHolder.ofFloat("rotation", 0.f, 270.f)); animator.setDuration((long) (200 * mSpeedFactor)); return animator; }
private void leftViewSliding(int formx, int tox, View view, long duration) { PropertyValuesHolder leftXPv = PropertyValuesHolder.ofFloat("x", formx, tox); ObjectAnimator leftOA = ObjectAnimator.ofPropertyValuesHolder(view, leftXPv).setDuration(duration); leftOA.setInterpolator(new DecelerateInterpolator()); leftOA.start(); leftOA.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); onLeftViewShorted(); } }); }
public void fadeFrame(Object caller, boolean takeControl, float alpha, int duration) { if (takeControl) { mBgAlphaController = caller; } if (mBgAlphaController != caller && mBgAlphaController != null) { return; } if (mFrameFade != null) { mFrameFade.cancel(); mFrameFade = null; } PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", alpha); mFrameFade = ObjectAnimator.ofPropertyValuesHolder(this, bgAlpha); mFrameFade.setDuration(duration); mFrameFade.start(); }
private void parentViewSliding( int fromx, int tox, View view, long duration, AnimatorListenerAdapter listener) { PropertyValuesHolder pvTY = PropertyValuesHolder.ofFloat("x", fromx, tox); ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(view, pvTY).setDuration(duration); objectAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // parentViewScrollX = ((Float) // valueAnimator.getAnimatedValue()).intValue(); changeListView(); } }); objectAnimator.addListener(listener); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.start(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override public ObjectAnimator getAppearingAnimator(Context context) { final Point outPoint = new Point(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getSize(outPoint); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( new Object(), PropertyValuesHolder.ofFloat("alpha", 0.f, 1.f), PropertyValuesHolder.ofFloat("translationY", outPoint.y / 2.f, 0.f), PropertyValuesHolder.ofFloat("rotation", -45.f, 0.f)); animator.setDuration((long) (200 * mSpeedFactor)); return animator; }
public static ObjectAnimator nope(View view) { int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium); PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe( View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f)); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500); }
@Override public void animateMenuClosing(Point center) { super.animateMenuOpening(center); setAnimating(true); Animator lastAnimation = null; for (int i = 0; i < menu.getSubActionItems().size(); i++) { PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat( View.TRANSLATION_X, -(menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2)); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat( View.TRANSLATION_Y, -(menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2)); PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, -720); PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0); final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder( menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA); animation.setDuration(DURATION); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.addListener( new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING)); if (i == 0) { lastAnimation = animation; } animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS); animation.start(); } if (lastAnimation != null) { lastAnimation.addListener(new LastAnimationListener()); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_change: imageView.setImageResource(R.drawable.toutiao__news_ic_video_selected); PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofFloat("alpha", 0.3f, 1f); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 0.3f, 1f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 0.3f, 1f); ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, pvhAlpha, pvhScaleX, pvhScaleY) .setDuration(300); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.start(); break; } }
// 关闭动画 private void closeAnim() { for (int i = 1; i < res.length; i++) { float angle = (90 * 1.0f / (res.length - 2)) * (i - 1); PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat( "translationX", (float) (Math.sin((angle * 1.57 / 90)) * 200), 0); PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat( "translationY", (float) (Math.cos((angle * 1.57 / 90)) * 200), 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageViewList.get(i), holder1, holder2); // ObjectAnimator animator = // ObjectAnimator.ofFloat(imageViewList.get(i), "translationY", i * 60, // 0); animator.setDuration(300); animator.start(); isNotExpand = true; } }
@OnOptionsItemSelected(R.id.action_zoom) public void enterFullscreen() { FragmentActivity activity = getActivity(); if (activity == null) return; if (isStaticImage(feedItem)) { boolean hq = settings.loadHqInZoomView(); Intent intent = ZoomViewActivity.newIntent(activity, feedItem, hq); startActivity(intent); } else { FullscreenParams params = new FullscreenParams(); ObjectAnimator.ofPropertyValuesHolder( viewer, ofFloat(View.ROTATION, params.rotation), ofFloat(View.TRANSLATION_Y, params.trY), ofFloat(View.SCALE_X, params.scale), ofFloat(View.SCALE_Y, params.scale)) .setDuration(500) .start(); repostHint.setVisibility(View.GONE); // hide content below swipeRefreshLayout.setVisibility(View.GONE); if (activity instanceof ToolbarActivity) { // hide the toolbar if required necessary ((ToolbarActivity) activity).getScrollHideToolbarListener().hide(); } viewer.setClipBoundsCompat(null); activity.supportInvalidateOptionsMenu(); registerExitFullscreenListener(); // forbid orientation changes while in fullscreen Screen.lockOrientation(activity); } }