Java Code Examples for android.animation.ObjectAnimator#setInterpolator()
The following examples show how to use
android.animation.ObjectAnimator#setInterpolator() .
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: LessonB.java From SchoolQuest with GNU General Public License v3.0 | 6 votes |
public void setUpSliderAnimation() { GameActivity gameActivity = GameActivity.getInstance(); ImageView slider = gameActivity.findViewById(R.id.lesson_b_craft_bar_slider); ImageView craftBar = gameActivity.findViewById(R.id.lesson_b_craft_bar); int craftBarWidth = craftBar.getDrawable().getIntrinsicWidth(); ObjectAnimator sliderAnimation = ObjectAnimator.ofFloat(slider, "translationX", -(craftBarWidth / 2) + (craftBarWidth / 27), (craftBarWidth / 2) - (craftBarWidth / 27)); int baseSliderTime = 250; sliderAnimation.setDuration(baseSliderTime + (attn * baseSliderTime)); sliderAnimation.setRepeatCount(-1); sliderAnimation.setRepeatMode(ValueAnimator.REVERSE); sliderAnimation.setInterpolator(new LinearInterpolator()); sliderAnimation.start(); }
Example 2
Source File: RapidFloatingActionContentLabelList.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onCollapseAnimator(AnimatorSet animatorSet) { int count = contentView.getChildCount(); for (int i = 0; i < count; i++) { View rootView = contentView.getChildAt(i); ImageView iconIv = RFABViewUtil.obtainView(rootView, R.id.rfab__content_label_list_icon_iv); if (null == iconIv) { return; } ObjectAnimator animator = new ObjectAnimator(); animator.setTarget(iconIv); animator.setFloatValues(0, 45f); animator.setPropertyName("rotation"); animator.setInterpolator(mOvershootInterpolator); animator.setStartDelay((count * i) * 20); animatorSet.playTogether(animator); } }
Example 3
Source File: NexusRotationCrossDrawable.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private void initObjectAnimator() { final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(this, "rotationAngle", 0, 180); objectAnimator.setInterpolator(LINEAR_INTERPOLATOR); objectAnimator.setDuration(ANIMATION_DURATION); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRotationAngle == 180) { objectAnimator.setIntValues(180, 360); objectAnimator.setStartDelay(ANIMATION_START_DELAY * 2); } else { objectAnimator.setIntValues(0, 180); objectAnimator.setStartDelay(ANIMATION_START_DELAY); mRotationAngle = 0; } objectAnimator.start(); } }); objectAnimator.start(); }
Example 4
Source File: FABsMenu.java From FABsMenu with Apache License 2.0 | 6 votes |
private void createRotatingDrawable() { RotatingDrawable dr = new RotatingDrawable(menuButtonIcon); final OvershootInterpolator interpolator = new OvershootInterpolator(); final ObjectAnimator collapseAnimator = ObjectAnimator .ofFloat(dr, "rotation", EXPANDED_PLUS_ROTATION, COLLAPSED_PLUS_ROTATION); final ObjectAnimator expandAnimator = ObjectAnimator .ofFloat(dr, "rotation", COLLAPSED_PLUS_ROTATION, EXPANDED_PLUS_ROTATION); collapseAnimator.setInterpolator(interpolator); expandAnimator.setInterpolator(interpolator); expandAnimation.play(expandAnimator); collapseAnimation.play(collapseAnimator); menuButton.setImageDrawable(dr); rotatingDrawable = dr; }
Example 5
Source File: CommonPropertyAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
public void startTransAnimation(View v) { float scale = getResources().getDisplayMetrics().density; ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(mShowTransAnimIV, "x", 20.0f*scale, 220.0f*scale); ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(mShowTransAnimIV, "y", 20.0f*scale, 220.0f*scale); ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(mShowTransAnimIV, "x", 220.0f*scale, 20.0f*scale); ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(mShowTransAnimIV, "y", 220.0f*scale, 20.0f*scale); objectAnimator1.setDuration(C.Int.ANIM_DURATION); objectAnimator2.setDuration(C.Int.ANIM_DURATION); objectAnimator3.setDuration(C.Int.ANIM_DURATION * 2); objectAnimator4.setDuration(C.Int.ANIM_DURATION * 2); objectAnimator1.setInterpolator(new AccelerateInterpolator()); objectAnimator2.setInterpolator(new DecelerateInterpolator()); objectAnimator3.setInterpolator(new LinearInterpolator()); objectAnimator4.setInterpolator(new AccelerateDecelerateInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); // Long version to set up animation set // animSet.play(anim1).before(anim2); // animSet.play(anim3).after(anim2); // animSet.play(anim3).with(anim4); // animSet.play(anim1).after(500); animatorSet.play(objectAnimator1).before(objectAnimator2).after(C.Int.ANIM_DURATION); animatorSet.play(objectAnimator3).after(objectAnimator2).with(objectAnimator4); animatorSet.start(); }
Example 6
Source File: ChartAnimator.java From iMoney with Apache License 2.0 | 5 votes |
/** * Animates the rendering of the chart on the y-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. * * @param durationMillis * @param easing */ public void animateY(int durationMillis, Easing.EasingOption easing) { if (android.os.Build.VERSION.SDK_INT < 11) return; ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f); animatorY.setInterpolator(Easing.getEasingFunctionFromOption(easing)); animatorY.setDuration(durationMillis); animatorY.addUpdateListener(mListener); animatorY.start(); }
Example 7
Source File: ViewInspectorToolbar.java From ViewInspector with Apache License 2.0 | 5 votes |
@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)); }
Example 8
Source File: PickerView.java From ColorPickerDialog with Apache License 2.0 | 5 votes |
/** * Set the color's alpha, between 0-1 (inclusive). * * @param alpha The color's alpha, between 0-1 (inclusive). * @param animate Whether to animate the change in values. */ public void setColorAlpha(int alpha, boolean animate) { if (this.alpha == null) return; if (animate && !isTrackingTouch) { ObjectAnimator animator = ObjectAnimator.ofInt(this.alpha, "progress", alpha); animator.setInterpolator(new DecelerateInterpolator()); animator.start(); } else { this.alpha.setProgress(alpha); } }
Example 9
Source File: StackViewAnimation.java From 365browser 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 10
Source File: VoIPActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@SuppressLint("ObjectAnimatorBinding") private ObjectAnimator createAlphaAnimator(Object target, int startVal, int endVal, int startDelay, int duration){ ObjectAnimator a=ObjectAnimator.ofInt(target, "alpha", startVal, endVal); a.setDuration(duration); a.setStartDelay(startDelay); a.setInterpolator(CubicBezierInterpolator.DEFAULT); return a; }
Example 11
Source File: AnimUtils.java From Android-utils with Apache License 2.0 | 5 votes |
/** * 指定的控件闪烁,用在提示等各种场景中 * * @param view 做动画的 View * @param duration 动画时长(毫秒),参考 2888 * @param repeatCount 动画重复的次数,参考 6 * @param values 透明度改变的值,参考 0, 0.66f, 1.0f, 0 */ public static ObjectAnimator shining(View view, int duration, int repeatCount, float ...values) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", values); animator.setDuration(duration); animator.setRepeatCount(repeatCount); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setRepeatMode(ValueAnimator.REVERSE); animator.start(); return animator; }
Example 12
Source File: AnimationUtils.java From AndroidHybridLib with Apache License 2.0 | 5 votes |
/** * progressBar递增动画 */ public static void startProgressAnimation(ProgressBar mProgressBar, int currentProgress , int newProgress) { ObjectAnimator animator = ObjectAnimator.ofInt(mProgressBar, "progress", currentProgress, newProgress); animator.setDuration(300); animator.setInterpolator(new DecelerateInterpolator()); animator.start(); }
Example 13
Source File: ExampleFlyinBounceHelper.java From android-ConstraintLayoutExamples with Apache License 2.0 | 5 votes |
/** * @param container * @hide */ @Override public void updatePreLayout(ConstraintLayout container) { if (mContainer!=container) { View[] views = getViews(container); for (int i = 0; i < mCount; i++) { View view = views[i]; ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationX", - 2000, 0).setDuration(1000); animator.setInterpolator(new BounceInterpolator()); animator.start(); } } mContainer = container; }
Example 14
Source File: Ripple.java From HeadsUp with GNU General Public License v2.0 | 5 votes |
private void exitSoftware(int radiusDuration, int opacityDuration) { final ObjectAnimator radiusAnim = ObjectAnimator.ofFloat(this, "radiusGravity", 1); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) radiusAnim.setAutoCancel(true); radiusAnim.setDuration(radiusDuration); radiusAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator xAnim = ObjectAnimator.ofFloat(this, "xGravity", 1); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) xAnim.setAutoCancel(true); xAnim.setDuration(radiusDuration); xAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator yAnim = ObjectAnimator.ofFloat(this, "yGravity", 1); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) yAnim.setAutoCancel(true); yAnim.setDuration(radiusDuration); yAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator opacityAnim = ObjectAnimator.ofFloat(this, "opacity", 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) opacityAnim.setAutoCancel(true); opacityAnim.setDuration(opacityDuration); opacityAnim.setInterpolator(LINEAR_INTERPOLATOR); opacityAnim.addListener(mAnimationListener); mAnimRadius = radiusAnim; mAnimOpacity = opacityAnim; mAnimX = xAnim; mAnimY = yAnim; radiusAnim.start(); opacityAnim.start(); xAnim.start(); yAnim.start(); }
Example 15
Source File: ChartAnimator.java From NetKnight with Apache License 2.0 | 5 votes |
/** * Animates the rendering of the chart on the y-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. * * @param durationMillis * @param easing */ public void animateY(int durationMillis, EasingFunction easing) { if (android.os.Build.VERSION.SDK_INT < 11) return; ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f); animatorY.setInterpolator(easing); animatorY.setDuration(durationMillis); animatorY.addUpdateListener(mListener); animatorY.start(); }
Example 16
Source File: MainActivity.java From rnd-android-wear-tesla with MIT License | 5 votes |
private void addScaleDownAnimation(List<Animator> animations, View button) { ObjectAnimator scaleDownXImage = ObjectAnimator.ofFloat(button, "scaleX", MAX_SCALE, MIN_SCALE); scaleDownXImage.setDuration(ANIMATION_DURATION); scaleDownXImage.setInterpolator(new AccelerateInterpolator()); animations.add(scaleDownXImage); ObjectAnimator scaleDownYImage = ObjectAnimator.ofFloat(button, "scaleY", MAX_SCALE, MIN_SCALE); scaleDownYImage.setDuration(ANIMATION_DURATION); scaleDownYImage.setInterpolator(new AccelerateInterpolator()); animations.add(scaleDownYImage); }
Example 17
Source File: FullImageActivity.java From chatui with Apache License 2.0 | 5 votes |
private void activityEnterAnim() { fullImage.setPivotX(0); fullImage.setPivotY(0); fullImage.setScaleX(mScaleX); fullImage.setScaleY(mScaleY); fullImage.setTranslationX(mLeft); fullImage.setTranslationY(mTop); fullImage.animate().scaleX(1).scaleY(1).translationX(0).translationY(0). setDuration(500).setInterpolator(new DecelerateInterpolator()).start(); ObjectAnimator objectAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.setDuration(500); objectAnimator.start(); }
Example 18
Source File: RotateLoading.java From In77Camera with MIT License | 5 votes |
private void startAnimator() { ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.0f, 1); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 0.0f, 1); scaleXAnimator.setDuration(300); scaleXAnimator.setInterpolator(new LinearInterpolator()); scaleYAnimator.setDuration(300); scaleYAnimator.setInterpolator(new LinearInterpolator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(scaleXAnimator, scaleYAnimator); animatorSet.start(); }
Example 19
Source File: NavigationWelcomeActivity.java From GifAssistant with Apache License 2.0 | 5 votes |
private void doViewPagerAnimation4(int pagerIndex) { // 停掉页面3的动画及显示 mCurrentPager3Flag = false; if (mCloudTransAnimationX1.isRunning()) { mCloudTransAnimationX1.cancel(); mCloudTransAnimationY1.cancel(); mCloudTransAnimation2.cancel(); mCloudTransAnimation3.cancel(); mCloudTransAnimation4.cancel(); } mNav3CloudImageView1.setVisibility(View.INVISIBLE); mNav3CloudImageView2.setVisibility(View.INVISIBLE); mNav3CloudImageView3.setVisibility(View.INVISIBLE); mNav3CloudImageView4.setVisibility(View.INVISIBLE); mRocketAnimationDrawable.stop(); ObjectAnimator objAnim = ObjectAnimator.ofFloat(mNav4TopImageView, "rotation", 0f, 10f); CycleInterpolator interpolator = new CycleInterpolator(3.0f); objAnim.setStartDelay(500); objAnim.setDuration(3000); objAnim.setRepeatCount(Animation.INFINITE);// Animation.INFINITE objAnim.setRepeatMode(Animation.RESTART); objAnim.setInterpolator(interpolator); mNav4TopImageView.setPivotX(mNav4TopImageView.getWidth()*0.47f); mNav4TopImageView.setPivotY(mNav4TopImageView.getHeight()*0.05f); objAnim.start(); mNavTopStaticAnimationSet.setTarget(mNav4bottomTextImageView); mNavTopStaticAnimationSet.start(); }
Example 20
Source File: ReduceAnimation.java From Depth with MIT License | 4 votes |
@Override public void prepareAnimators(DepthRelativeLayout target, int index, int animationDelay) { final TimeInterpolator interpolator = TransitionHelper.interpolator; final float density = target.getResources().getDisplayMetrics().density; target.setPivotY(TransitionHelper.getDistanceToCenter(target)); target.setPivotX(TransitionHelper.getDistanceToCenterX(target)); target.setCameraDistance(10000 * density); final long totalDuration = reduceConfiguration.getDuration(); final long duration = (long) (totalDuration * 0.7f); final long translationDuration = (long) (0.125 * totalDuration); final float finalTranslationY = (index * -1 * 8) * density + reduceConfiguration.getTranslationY() * density; final float finalElevation = reduceConfiguration.getElevation() * density; final float finalScale = reduceConfiguration.getScale(); final float finalRotationX = reduceConfiguration.getRotationX(); final float finalRotationZ = reduceConfiguration.getRotationZ(); { //rotation X & Z final ObjectAnimator rotationX = ObjectAnimator.ofFloat(target, View.ROTATION_X, finalRotationX); rotationX.setDuration(duration); rotationX.setInterpolator(interpolator); rotationX.setStartDelay(animationDelay); attachListener(rotationX); add(rotationX); final ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, finalRotationZ); rotation.setDuration(totalDuration); rotation.setInterpolator(interpolator); rotation.setStartDelay(animationDelay); add(rotation); } { //shadow final ObjectAnimator elevation = ObjectAnimator.ofFloat(target, "CustomShadowElevation", target.getCustomShadowElevation(), finalElevation); elevation.setDuration(duration); elevation.setInterpolator(interpolator); elevation.setStartDelay(animationDelay); add(elevation); } { //scale final ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, finalScale); scaleX.setDuration(duration); scaleX.setInterpolator(interpolator); scaleX.setStartDelay(animationDelay); add(scaleX); final ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, finalScale); scaleY.setDuration(duration); scaleY.setInterpolator(interpolator); scaleY.setStartDelay(animationDelay); add(scaleY); } { //translation Y final ObjectAnimator translationY = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, finalTranslationY); translationY.setDuration(translationDuration); translationY.setInterpolator(interpolator); translationY.setStartDelay(animationDelay); add(translationY); } }