Java Code Examples for android.animation.PropertyValuesHolder#ofFloat()
The following examples show how to use
android.animation.PropertyValuesHolder#ofFloat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RippleAnimator.java From TheGlowingLoader with Apache License 2.0 | 6 votes |
public void startCircleMajor(final Callback callback) { PropertyValuesHolder rp = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius); PropertyValuesHolder ap = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .15f), 0); ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(rp, ap, sp); va.setInterpolator(new AccelerateInterpolator(.4f)); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius = (float) animation.getAnimatedValue("radius"); circleAlpha = (float) animation.getAnimatedValue("alpha"); circleStroke = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va.setDuration(450); va.start(); }
Example 2
Source File: ZoomTransitionFactory.java From android-slideshow-widget with Apache License 2.0 | 6 votes |
@Override public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) { target.setAlpha(0); target.setScaleX(SCALE_FACTOR); target.setScaleY(SCALE_FACTOR); target.setTranslationX(0); target.setTranslationY(0); target.setRotationX(0); target.setRotationY(0); final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, scaleX, scaleY, alpha); animator.setDuration(getDuration()); animator.setInterpolator(getInterpolator()); return animator; }
Example 3
Source File: MDTouchHelper.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 6 votes |
private void animStart(float velocityX, float velocityY) { animCancel(); PropertyValuesHolder hvx = PropertyValuesHolder.ofFloat("vx", velocityX, 0); PropertyValuesHolder hvy = PropertyValuesHolder.ofFloat("vy", velocityY, 0); valueAnimator = ValueAnimator.ofPropertyValuesHolder(hvx, hvy).setDuration(mFlingConfig.getDuring()); valueAnimator.setInterpolator(mFlingConfig.getInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { private long lastTime = 0; @Override public void onAnimationUpdate(ValueAnimator animation) { long now = animation.getCurrentPlayTime(); long dur = (now - lastTime); float sx = (float) animation.getAnimatedValue("vx") * dur / -1000 * mFlingConfig.getSensitivity(); float sy = (float) animation.getAnimatedValue("vy") * dur / -1000 * mFlingConfig.getSensitivity(); lastTime = now; if (mAdvanceGestureListener != null){ mAdvanceGestureListener.onDrag(scaled(sx), scaled(sy)); } } }); valueAnimator.start(); }
Example 4
Source File: StackViewAnimation.java From delion with Apache License 2.0 | 5 votes |
private Animator createNewTabOpenedAnimator( StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) { Tab tab = model.getTabAt(focusIndex); if (tab == null || !tab.isNativePage()) return null; View view = tab.getView(); if (view == null) return null; // Set up the view hierarchy if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); ViewGroup bgView = new FrameLayout(view.getContext()); bgView.setBackgroundColor(tab.getBackgroundColor()); bgView.addView(view); container.addView( bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // Update any compositor state that needs to change if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) { tabs[focusIndex].setAlpha(0.f); } // Build the view animations PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f); PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( bgView, xScale, yScale, alpha); animator.setDuration(TAB_OPENED_ANIMATION_DURATION); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE); float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx; bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP); bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx); return animator; }
Example 5
Source File: StackViewAnimation.java From AndroidChromium with Apache License 2.0 | 5 votes |
private Animator createNewTabOpenedAnimator( StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) { Tab tab = model.getTabAt(focusIndex); if (tab == null || !tab.isNativePage()) return null; View view = tab.getView(); if (view == null) return null; // Set up the view hierarchy if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); ViewGroup bgView = new FrameLayout(view.getContext()); bgView.setBackgroundColor(tab.getBackgroundColor()); bgView.addView(view); container.addView( bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // Update any compositor state that needs to change if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) { tabs[focusIndex].setAlpha(0.f); } // Build the view animations PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f); PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( bgView, xScale, yScale, alpha); animator.setDuration(TAB_OPENED_ANIMATION_DURATION); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE); float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx; bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP); bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx); return animator; }
Example 6
Source File: DefaultAnimationHandler.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@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()); } }
Example 7
Source File: CustomAnimationActivity.java From Reachability with Apache License 2.0 | 5 votes |
private PropertyValuesHolder[] toRightAnimation() { PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat( "translationX", 0f, getWidth() ); PropertyValuesHolder holderR = PropertyValuesHolder.ofFloat("rotation", 0f, 360f); PropertyValuesHolder[] holders = {holderX, holderR}; return holders; }
Example 8
Source File: ObjectAnimatorCompatBase.java From MaterialProgressBar with Apache License 2.0 | 5 votes |
@NonNull public static ObjectAnimator ofFloat(@Nullable Object target, @NonNull String xPropertyName, @NonNull String yPropertyName, @NonNull Path path) { float[] xValues = new float[NUM_POINTS]; float[] yValues = new float[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofFloat(xPropertyName, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofFloat(yPropertyName, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
Example 9
Source File: SquareSpinIndicator.java From LazyRecyclerAdapter with MIT License | 5 votes |
@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; }
Example 10
Source File: DragItem.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
void startDrag(View startFromView, float touchX, float touchY) { show(); onBindDragView(startFromView, mDragView); onMeasureDragView(startFromView, mDragView); onStartDragAnimation(mDragView); float startX = startFromView.getX() - (mDragView.getMeasuredWidth() - startFromView.getMeasuredWidth()) / 2 + mDragView .getMeasuredWidth() / 2; float startY = startFromView.getY() - (mDragView.getMeasuredHeight() - startFromView.getMeasuredHeight()) / 2 + mDragView .getMeasuredHeight() / 2; if (mSnapToTouch) { mPosTouchDx = 0; mPosTouchDy = 0; setPosition(touchX, touchY); setAnimationDx(startX - touchX); setAnimationDY(startY - touchY); PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("AnimationDx", mAnimationDx, 0); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("AnimationDY", mAnimationDy, 0); ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(this, pvhX, pvhY); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.start(); } else { mPosTouchDx = startX - touchX; mPosTouchDy = startY - touchY; setPosition(touchX, touchY); } }
Example 11
Source File: SliderAnimationHandler.java From android-open-project-demo with Apache License 2.0 | 5 votes |
@Override public void animateMenuClosing(Point center) { super.animateMenuClosing(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)-DIST); PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, -730); PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X,2, 1,0); PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y,2, 1,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((i) * LAG_BETWEEN_ITEMS); animation.start(); } if(lastAnimation != null) { lastAnimation.addListener(new LastAnimationListener()); } }
Example 12
Source File: CityWeatherActivity.java From LittleFreshWeather with Apache License 2.0 | 5 votes |
@Override public void run() { ++mSpecialWeatherNumRain; if (mSpecialWeatherNumRain <= mSpecialWeatherNumLimitRain) { int screenHeight = DensityUtil.getScreenHeight(CityWeatherActivity.this); int screenWidth = DensityUtil.getScreenWidth(CityWeatherActivity.this); int fX = mRandom.nextInt(screenWidth << 1); int tX = fX - (int)(screenHeight * 0.58); ImageView imageView = new ImageView(CityWeatherActivity.this); imageView.setVisibility(View.VISIBLE); mPresenter.getImageViewSrc(imageView, mRainIconId); //imageView.setImageResource(mRainIconId); imageView.setRotation(30); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(fX, 0, 0, 0); rlBackgroundView.addView(imageView, layoutParams); PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("translationY", -100, screenHeight + 100); PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("translationX", fX, tX); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView, holderX, holderY); if ((mSpecialWeatherNumRain & 0x1) == 0) { animator.setDuration(mSpecialWeatherSpeedLimitRain); } else { animator.setDuration(mSpecialWeatherSpeedLimitRain + RAIN_SPEED_OFFSET); } animator.setRepeatMode(ObjectAnimator.RESTART); animator.setRepeatCount(ObjectAnimator.INFINITE); animator.setInterpolator(new LinearInterpolator()); animator.start(); mHandler.postDelayed(rainProc, RAIN_GEN_INTERVAL); } }
Example 13
Source File: PropertyAnimationActivity.java From Android-Animation-Set with Apache License 2.0 | 5 votes |
/** * ObjectAnimator: You can also create multiple animations by PropertyValuesHolder. * <p> * ValueAnimator has the same method, but we don't use it that way. #ValueAnimator.ofPropertyValuesHolder()# * * @return */ public Animator getObjectAnimatorByPropertyValuesHolder() { PropertyValuesHolder bgColorAnimator = PropertyValuesHolder.ofObject("backgroundColor", new ArgbEvaluator(), 0xff009688, 0xff795548); PropertyValuesHolder rotationXAnimator = PropertyValuesHolder.ofFloat("rotationX", 0f, 360f); ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(mPuppet, bgColorAnimator, rotationXAnimator); objectAnimator.setDuration(3000); objectAnimator.setRepeatCount(1); objectAnimator.setRepeatMode(ValueAnimator.REVERSE); return objectAnimator; }
Example 14
Source File: GiftAnimationUtil.java From LiveGiftLayout with Apache License 2.0 | 5 votes |
/** * @param target * @return 送礼数字变化 */ public static ObjectAnimator scaleGiftNum(final TextView target) { PropertyValuesHolder anim4 = PropertyValuesHolder.ofFloat("scaleX", 1.2f, 0.8f, 1f); PropertyValuesHolder anim5 = PropertyValuesHolder.ofFloat("scaleY", 1.2f, 0.8f, 1f); PropertyValuesHolder anim6 = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f, 1f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, anim4, anim5, anim6).setDuration(400); return animator; }
Example 15
Source File: ObjectAnimatorCompatBase.java From MaterialProgressBar with Apache License 2.0 | 5 votes |
@NonNull public static <T> ObjectAnimator ofFloat(@Nullable T target, @NonNull Property<T, Float> xProperty, @NonNull Property<T, Float> yProperty, @NonNull Path path) { float[] xValues = new float[NUM_POINTS]; float[] yValues = new float[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofFloat(xProperty, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofFloat(yProperty, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
Example 16
Source File: GiftFrameLayout.java From LiveGiftLayout with Apache License 2.0 | 5 votes |
public void firstHideLayout() { PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(GiftFrameLayout.this, alpha); animator.setStartDelay(0); animator.setDuration(0); animator.start(); }
Example 17
Source File: SlideDown.java From Flubber with Apache License 2.0 | 5 votes |
@Override public Animator getAnimationFor(AnimationBody animationBody, View view) { final float startY = DimensionUtils.dp2px(-800); final float endY = 0f; final PropertyValuesHolder translationPVH = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, startY, endY); final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(view, translationPVH); return animation; }
Example 18
Source File: Workspace.java From TurboLauncher with Apache License 2.0 | 5 votes |
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete, final boolean stripEmptyScreens) { PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f); final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); mRemoveEmptyScreenRunnable = new Runnable() { @Override public void run() { if (hasExtraEmptyScreen()) { mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); removeView(cl); if (stripEmptyScreens) { stripEmptyScreens(); } } } }; ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha); oa.setDuration(duration); oa.setStartDelay(delay); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRemoveEmptyScreenRunnable != null) { mRemoveEmptyScreenRunnable.run(); } if (onComplete != null) { onComplete.run(); } } }); oa.start(); }
Example 19
Source File: AnimatorUtils.java From ArcLayout with Apache License 2.0 | 4 votes |
public static PropertyValuesHolder scaleY(float... values) { return PropertyValuesHolder.ofFloat(SCALE_Y, values); }
Example 20
Source File: AnimatorUtils.java From Qiitanium with MIT License | 4 votes |
public static PropertyValuesHolder ofRotation(float... values) { return PropertyValuesHolder.ofFloat(ROTATION, values); }