當前位置: 首頁>>代碼示例>>Java>>正文


Java ValueAnimator.setEvaluator方法代碼示例

本文整理匯總了Java中android.animation.ValueAnimator.setEvaluator方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAnimator.setEvaluator方法的具體用法?Java ValueAnimator.setEvaluator怎麽用?Java ValueAnimator.setEvaluator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.setEvaluator方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setColor

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip
 * With a color transition animation
 *
 * @param color    the final color
 * @param duration the transition color animation duration
 */
void setColor(int color, int duration) {
    final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setDuration(duration);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final int animatedValue = (Integer) animation.getAnimatedValue();
            int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
            mHeader.headerBackground.setBackgroundColor(colorAlpha);
            mHeader.statusBackground.setBackgroundColor(colorAlpha);
            mHeader.toolbar.setBackgroundColor(colorAlpha);
            mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
            mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);

            //set the new color as MaterialViewPager's color
            settings.color = animatedValue;
        }
    });
    colorAnim.start();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:MaterialViewPagerAnimator.java

示例2: createAppearBackgroundAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private Animator createAppearBackgroundAnimator() {
    int startColor = ResourcesCompat.getColor(getResources(),
            BACGROUND_TRANSPARENT_COLOR_RES,
            getContext().getTheme()
    );
    int finColor = ResourcesCompat.getColor(getResources(),
            BACKGROUND_COLOR_RES,
            getContext().getTheme()
    );
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, finColor);
    anim.setEvaluator(ArgbEvaluator.getInstance());
    anim.setStartDelay(ANIMATION_DURATION / 2);
    anim.setDuration(ANIMATION_DURATION / 2);
    anim.addUpdateListener(animation -> {
        int color = (int) animation.getAnimatedValue();
        setBackgroundColor(color);
    });
    return anim;
}
 
開發者ID:roshakorost,項目名稱:Phial,代碼行數:21,代碼來源:ExpandedView.java

示例3: ease

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void ease(final View view) {
    Easing easing = new Easing(1000);
    AnimatorSet animatorSet = new AnimatorSet();
    float fromY = 600;
    float toY = view.getTop();
    ValueAnimator valueAnimatorY = ValueAnimator.ofFloat(fromY,toY);

    valueAnimatorY.setEvaluator(easing);

    valueAnimatorY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setTranslationY((float) animation.getAnimatedValue());
        }
    });

    animatorSet.playTogether(valueAnimatorY);
    animatorSet.setDuration(700);
    animatorSet.start();
}
 
開發者ID:ahmadnurhidayat,項目名稱:Sign-Up,代碼行數:21,代碼來源:SignUp.java

示例4: ease2

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void ease2(final View view) {
    Easing easing = new Easing(1200);
    AnimatorSet animatorSet = new AnimatorSet();
    float fromY = 600;
    float toY = view.getTop();
    ValueAnimator valueAnimatorY = ValueAnimator.ofFloat(fromY,toY);

    valueAnimatorY.setEvaluator(easing);

    valueAnimatorY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setTranslationY((float) animation.getAnimatedValue());
        }
    });

    animatorSet.playTogether(valueAnimatorY);
    animatorSet.setDuration(1100);
    animatorSet.start();
}
 
開發者ID:ahmadnurhidayat,項目名稱:Sign-Up,代碼行數:21,代碼來源:SignUp.java

示例5: recolorBackground

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public static void recolorBackground(final View view,
                                     final int startColor,
                                     final int endColor,
                                     final int duration) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, endColor);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setBackgroundColor((Integer) animation.getAnimatedValue());
        }
    });
    anim.setDuration(duration);
    anim.start();
}
 
開發者ID:interactiveservices,項目名稱:utils-android,代碼行數:17,代碼來源:AnimUtils.java

示例6: setCodeSegment

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void setCodeSegment(final TextView codeView, String segment) {
  if (Build.VERSION.SDK_INT >= 11) {
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setObjectValues(0, Integer.parseInt(segment));

    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        int value = (int) animation.getAnimatedValue();
        codeView.setText(String.format("%05d", value));
      }
    });

    valueAnimator.setEvaluator(new TypeEvaluator<Integer>() {
      public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
        return Math.round(startValue + (endValue - startValue) * fraction);
      }
    });

    valueAnimator.setDuration(1000);
    valueAnimator.start();
  } else {
    codeView.setText(segment);
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:27,代碼來源:VerifyIdentityActivity.java

示例7: createColorAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * this method replace for ValueAnimator.ofArgb() support below sdk 6.0
 *
 * @param values
 * @return
 */
private ValueAnimator createColorAnimation(int... values) {
    ValueAnimator colorAnimation = new ValueAnimator();
    colorAnimation.setIntValues(values);
    colorAnimation.setEvaluator(new ArgbEvaluator());
    colorAnimation.setDuration(ANIMATION_DURATION);
    return colorAnimation;
}
 
開發者ID:arjinmc,項目名稱:AndroidButtonLib,代碼行數:14,代碼來源:SubmitButton.java

示例8: newArgbValueAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@NonNull
private static ValueAnimator newArgbValueAnimator(int[] colors) {
    // Equivalent to ValueAnimator.ofArgb() which is only for API 21+.
    ValueAnimator animator = ValueAnimator.ofInt(colors);
    animator.setEvaluator(new ArgbEvaluator());
    return animator;
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:8,代碼來源:NumberPadTimePickerBottomSheetComponent.java

示例9: animateColors

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void animateColors(int previousColor, int color) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(previousColor, color);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
           setColors((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim.setDuration(150);
    anim.start();
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:15,代碼來源:BottomBarTab.java


注:本文中的android.animation.ValueAnimator.setEvaluator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。