Java Code Examples for android.animation.ObjectAnimator#setEvaluator()
The following examples show how to use
android.animation.ObjectAnimator#setEvaluator() .
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: SettingPopup.java From eBook with Apache License 2.0 | 6 votes |
private void setTheme(int theme) { ObjectAnimator animator = ObjectAnimator .ofInt(mCardView, "cardBackgroundColor", mPopupColors[mTheme], mPopupColors[theme]) .setDuration(500); animator.setEvaluator(new ArgbEvaluator()); animator.start(); mTheme = theme; setCurThemeBtn(); setCurSeekBarStyle(); setCurFlipStyleBtn(); mSwitchView.setMaskColor(mStrokeColors[mTheme]); if (mListener != null) mListener.onThemeChanged(mTheme); }
Example 2
Source File: ViewUtils.java From animation-samples with Apache License 2.0 | 6 votes |
/** * Create a color change animation over a foreground property of a {@link FrameLayout}. * * @param target The target view. * @param startColorRes The color to start from. * @param targetColorRes The color this animation will end with. * @param interpolator The interpolator to use. * @return The color change animation. */ @NonNull public static ObjectAnimator createColorChange(@NonNull FrameLayout target, @ColorRes int startColorRes, @ColorRes int targetColorRes, @NonNull Interpolator interpolator) { Context context = target.getContext(); final int startColor = ContextCompat.getColor(context, startColorRes); final int targetColor = ContextCompat.getColor(context, targetColorRes); ObjectAnimator colorChange = ObjectAnimator.ofInt(target, ViewUtils.FOREGROUND_COLOR, startColor, targetColor); colorChange.setEvaluator(new ArgbEvaluator()); colorChange.setInterpolator(interpolator); colorChange.setDuration(context.getResources() .getInteger(android.R.integer.config_longAnimTime)); return colorChange; }
Example 3
Source File: VoIPActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void hideRetry(){ if(retryAnim!=null) retryAnim.cancel(); retrying=false; //bottomButtons.setVisibility(View.VISIBLE); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44); colorAnim.setEvaluator(new ArgbEvaluator()); } AnimatorSet set=new AnimatorSet(); set.playTogether( colorAnim, ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0), ObjectAnimator.ofFloat(endBtn, "translationX", 0), ObjectAnimator.ofFloat(cancelBtn, "alpha", 0)//, //ObjectAnimator.ofFloat(bottomButtons, "alpha", 1) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation){ cancelBtn.setVisibility(View.GONE); endBtn.setEnabled(true); retryAnim=null; } }); retryAnim=set; set.start(); }
Example 4
Source File: FabTransformationBehavior.java From material-components-android with Apache License 2.0 | 5 votes |
private void createColorAnimation( @NonNull View dependency, View child, boolean expanded, boolean currentlyAnimating, @NonNull FabTransformationSpec spec, @NonNull List<Animator> animations, List<AnimatorListener> unusedListeners) { if (!(child instanceof CircularRevealWidget)) { return; } CircularRevealWidget circularRevealChild = (CircularRevealWidget) child; @ColorInt int tint = getBackgroundTint(dependency); @ColorInt int transparent = tint & 0x00FFFFFF; ObjectAnimator animator; if (expanded) { if (!currentlyAnimating) { circularRevealChild.setCircularRevealScrimColor(tint); } animator = ObjectAnimator.ofInt( circularRevealChild, CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR, transparent); } else { animator = ObjectAnimator.ofInt( circularRevealChild, CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR, tint); } animator.setEvaluator(ArgbEvaluatorCompat.getInstance()); MotionTiming timing = spec.timings.getTiming("color"); timing.apply(animator); animations.add(animator); }
Example 5
Source File: ViewUtil.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) { ObjectAnimator animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor); } else { animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor); animator.setEvaluator(new ArgbEvaluator()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); } animator.setDuration(VINYL_MUSIC_PLAYER_ANIM_TIME); return animator; }
Example 6
Source File: ViewUtil.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) { ObjectAnimator animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor); } else { animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor); animator.setEvaluator(new ArgbEvaluator()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); } animator.setDuration(PHONOGRAPH_ANIM_TIME); return animator; }
Example 7
Source File: TextColorAnimExpectation.java From ExpectAnim with Apache License 2.0 | 5 votes |
@Override public Animator getAnimator(View viewToMove) { if (viewToMove instanceof TextView) { final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(viewToMove, "textColor", ((TextView) viewToMove).getCurrentTextColor(), textColor); objectAnimator.setEvaluator(new ArgbEvaluator()); return objectAnimator; } else { return null; } }
Example 8
Source File: IntroScreenActivity.java From andOTP with MIT License | 5 votes |
public void flashWarning() { if (authWarnings.getText().toString().isEmpty()) { authWarnings.setVisibility(View.GONE); } else { authWarnings.setVisibility(View.VISIBLE); ObjectAnimator animator = ObjectAnimator.ofInt(authWarnings, "backgroundColor", Color.TRANSPARENT, getResources().getColor(R.color.colorAccent), Color.TRANSPARENT); animator.setDuration(500); animator.setRepeatCount(0); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setEvaluator(new ArgbEvaluator()); animator.start(); } }
Example 9
Source File: VoIPActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void showRetry() { if (retryAnim != null) retryAnim.cancel(); endBtn.setEnabled(false); retrying = true; cancelBtn.setVisibility(View.VISIBLE); cancelBtn.setAlpha(0); AnimatorSet set = new AnimatorSet(); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); colorAnim.setEvaluator(new ArgbEvaluator()); } set.playTogether( ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1), ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2), colorAnim, ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//, //ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //bottomButtons.setVisibility(View.GONE); retryAnim = null; endBtn.setEnabled(true); } }); retryAnim = set; set.start(); }
Example 10
Source File: VoIPActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void showRetry() { if (retryAnim != null) retryAnim.cancel(); endBtn.setEnabled(false); retrying = true; cancelBtn.setVisibility(View.VISIBLE); cancelBtn.setAlpha(0); AnimatorSet set = new AnimatorSet(); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); colorAnim.setEvaluator(new ArgbEvaluator()); } set.playTogether( ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1), ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2), colorAnim, ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//, //ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //bottomButtons.setVisibility(View.GONE); retryAnim = null; endBtn.setEnabled(true); } }); retryAnim = set; set.start(); }
Example 11
Source File: VoIPActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void showRetry(){ if(retryAnim!=null) retryAnim.cancel(); endBtn.setEnabled(false); retrying=true; cancelBtn.setVisibility(View.VISIBLE); cancelBtn.setAlpha(0); AnimatorSet set=new AnimatorSet(); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); colorAnim.setEvaluator(new ArgbEvaluator()); } set.playTogether( ObjectAnimator.ofFloat(cancelBtn, "alpha", 0, 1), ObjectAnimator.ofFloat(endBtn, "translationX", 0, content.getWidth()/2-AndroidUtilities.dp(52)-endBtn.getWidth()/2), colorAnim, ObjectAnimator.ofFloat(endBtnIcon, "rotation", 0, -135)//, //ObjectAnimator.ofFloat(spkToggle, "alpha", 0), //ObjectAnimator.ofFloat(micToggle, "alpha", 0), //ObjectAnimator.ofFloat(chatBtn, "alpha", 0) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation){ //bottomButtons.setVisibility(View.GONE); retryAnim=null; endBtn.setEnabled(true); } }); retryAnim=set; set.start(); }
Example 12
Source File: Fragment1.java From CreditSesameRingView with Apache License 2.0 | 5 votes |
public void startColorChangeAnim() { ObjectAnimator animator = ObjectAnimator.ofInt(mLayout, "backgroundColor", mColors); animator.setDuration(3000); animator.setEvaluator(new ArgbEvaluator()); animator.start(); }
Example 13
Source File: CommentFragment.java From VideoDemoJava with MIT License | 5 votes |
private void initData() { mAttr = getArguments().getParcelable("attr"); //背景色动画 ObjectAnimator animator = ObjectAnimator.ofInt(mRoot, "backgroundColor", 0x00000000, 0xff000000); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(DURATION); animator.start(); location = new int[2]; mContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { //绘制完毕,开始执行动画 mContainer.getViewTreeObserver().removeOnPreDrawListener(this); mContainer.getLocationOnScreen(location); mContainer.setTranslationX(mAttr.getX() - location[0]); mContainer.setTranslationY(mAttr.getY() - location[1]); mContainer.setScaleX(mAttr.getWidth() / (float) mContainer.getMeasuredWidth()); mContainer.setScaleY(mAttr.getHeight() / (float) mContainer.getMeasuredHeight()); mRecycler.setAlpha(0); mTextView.setAlpha(0); mClose.setAlpha(0); mCommentNum.setAlpha(0); mContainer.animate().translationX(0).translationY(0).scaleX(1).scaleY(1).setDuration(DURATION); mRecycler.animate().alpha(1).setDuration(DURATION); mTextView.animate().alpha(1).setDuration(DURATION); mClose.animate().alpha(1).setDuration(DURATION); mCommentNum.animate().alpha(1).setDuration(DURATION); AssistPlayer.get().play(mContainer, null); return true; } }); mRecycler.setLayoutManager(new LinearLayoutManager(getContext())); mAdapter = new CommentAdapter(getContext(), mList); mRecycler.setAdapter(mAdapter); }
Example 14
Source File: VideoListFragment.java From VideoDemoJava with MIT License | 5 votes |
private void initData() { mAttr = getArguments().getParcelable("attr"); NewsBean bean = getArguments().getParcelable("news"); mList = new ArrayList<>(5); mList.add(bean); mAdapter = new VideoListAdapter(mList, getContext()); mAdapter.setAttach(getArguments().getBoolean("isAttach", false)); mAdapter.setAttr(mAttr); mAdapter.setOnAnimationFinishListener(this); mAdapter.setOnMessageClickListener(this); mAdapter.setOnVideoPlayClickListener(this); mRecycler.setAdapter(mAdapter); mRecycler.setLayoutManager(new LinearLayoutManager(getContext())); mRecycler.setItemAnimator(new FadeInUpAnimator()); mRecycler.addItemDecoration(new EmptyItemDecoration(Util.dip2px(getContext(), 40))); mBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isShowComment) { closeCommentFragment(); } else { if (onBackClickListener != null) { onBackClickListener.removeVideoListFragment(); } } } }); //背景颜色从透明黑色过度到黑色 ObjectAnimator animator = ObjectAnimator.ofInt(mRoot, "backgroundColor", 0x00000000, 0xff000000); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(DURATION); animator.start(); if (!mAdapter.isAttach()) { //不需要过渡动画,直接请求数据 onAnimationEnd(); } }
Example 15
Source File: AnimationBuilder.java From ViewAnimator with Apache License 2.0 | 5 votes |
public AnimationBuilder backgroundColor(int... colors) { for (View view : views) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } return this; }
Example 16
Source File: ShareCard.java From timecat with Apache License 2.0 | 5 votes |
public void showText(TextView textView, String text, int fromColor, int toColor) { textView.setText(text); ObjectAnimator objectAnimator = ObjectAnimator.ofInt(textView, "textColor", fromColor, toColor); objectAnimator.setEvaluator(new ArgbEvaluator()); objectAnimator.setDuration(300); objectAnimator.setRepeatCount(0); objectAnimator.start(); }
Example 17
Source File: AbsQuizView.java From android-topeka with Apache License 2.0 | 5 votes |
private void animateForegroundColor(@ColorInt final int targetColor) { ObjectAnimator animator = ObjectAnimator.ofInt(this, ViewUtils.FOREGROUND_COLOR, Color.TRANSPARENT, targetColor); animator.setEvaluator(new ArgbEvaluator()); animator.setStartDelay(FOREGROUND_COLOR_CHANGE_DELAY); animator.start(); }
Example 18
Source File: VoIPActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void showRetry(){ if(retryAnim!=null) retryAnim.cancel(); endBtn.setEnabled(false); retrying=true; cancelBtn.setVisibility(View.VISIBLE); cancelBtn.setAlpha(0); AnimatorSet set=new AnimatorSet(); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); colorAnim.setEvaluator(new ArgbEvaluator()); } set.playTogether( ObjectAnimator.ofFloat(cancelBtn, "alpha", 0, 1), ObjectAnimator.ofFloat(endBtn, "translationX", 0, content.getWidth()/2-AndroidUtilities.dp(52)-endBtn.getWidth()/2), colorAnim, ObjectAnimator.ofFloat(endBtnIcon, "rotation", 0, -135)//, //ObjectAnimator.ofFloat(spkToggle, "alpha", 0), //ObjectAnimator.ofFloat(micToggle, "alpha", 0), //ObjectAnimator.ofFloat(chatBtn, "alpha", 0) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation){ //bottomButtons.setVisibility(View.GONE); retryAnim=null; endBtn.setEnabled(true); } }); retryAnim=set; set.start(); }
Example 19
Source File: AnimatorUtils.java From MousePaint with MIT License | 4 votes |
public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) { ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", new int[]{preColor, currColor}); animator.setDuration(duration); animator.setEvaluator(new ArgbEvaluator()); animator.start(); }
Example 20
Source File: AnimatorUtils.java From NBAPlus with Apache License 2.0 | 3 votes |
/** * 将View的背景颜色更改,使背景颜色转换更和谐的过渡动画 * * @param view 要改变背景颜色的View * @param preColor 上个颜色值 * @param currColor 当前颜色值 * @param duration 动画持续时间 */ public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) { ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", new int[]{preColor, currColor}); animator.setDuration(duration); animator.setEvaluator(new ArgbEvaluator()); animator.start(); }