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


Java ObjectAnimator.ofArgb方法代碼示例

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


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

示例1: startColorGradientAnim

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void startColorGradientAnim(int duration, final View view, @Nullable Animator.AnimatorListener listener, int... values) {
    final ValueAnimator anim = ObjectAnimator.ofArgb(values);
    anim.setDuration(duration);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int va = (int) animation.getAnimatedValue();
            view.setBackgroundColor(va);
        }
    });
    if (listener != null) {
        anim.addListener(listener);
    }
    anim.start();
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:17,代碼來源:AnimationUtils.java

示例2: prepareStateChange

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public void prepareStateChange(State toState, AnimatorSet targetAnim) {
    int finalAlpha = getAlphaForState(toState);
    if (targetAnim == null) {
        mBgPaint.setAlpha(finalAlpha);
        invalidate();
    } else {
        ObjectAnimator anim = ObjectAnimator.ofArgb(mBgPaint, "alpha", finalAlpha);
        anim.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                invalidate();
            }
        });
        targetAnim.play(anim);
    }
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:18,代碼來源:QsbBlockerView.java

示例3: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}
 
開發者ID:AdityaAnand1,項目名稱:Morphing-Material-Dialogs,代碼行數:40,代碼來源:MorphDialogToFab.java

示例4: createColorAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
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;
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:16,代碼來源:ViewUtil.java

示例5: createArgbAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
static ObjectAnimator createArgbAnimator(View view, String propertyName, int startColor, int endColor) {
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		return ObjectAnimator.ofObject(view, propertyName, new TypeEvaluator() {
			@Override
			public Object evaluate(float fraction, Object startValue, Object endValue) {
				int startInt = (Integer) startValue;
				int startA = (startInt >> 24) & 0xff;
				int startR = (startInt >> 16) & 0xff;
				int startG = (startInt >> 8) & 0xff;
				int startB = startInt & 0xff;

				int endInt = (Integer) endValue;
				int endA = (endInt >> 24) & 0xff;
				int endR = (endInt >> 16) & 0xff;
				int endG = (endInt >> 8) & 0xff;
				int endB = endInt & 0xff;

				return (startA + (int)(fraction * (endA - startA))) << 24 |
						(startR + (int)(fraction * (endR - startR))) << 16 |
						(startG + (int)(fraction * (endG - startG))) << 8 |
						(startB + (int)(fraction * (endB - startB)));
			}
		}, startColor, endColor);
	} else {
		return ObjectAnimator.ofArgb(view, propertyName, startColor, endColor);
	}
}
 
開發者ID:fython,項目名稱:MaterialStepperView,代碼行數:28,代碼來源:ViewUtils.java

示例6: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}
 
開發者ID:li-yu,項目名稱:Huahui-Android,代碼行數:41,代碼來源:MorphDialogToFab.java

示例7: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in))
                    .start();
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}
 
開發者ID:AdityaAnand1,項目名稱:Morphing-Material-Dialogs,代碼行數:44,代碼來源:MorphFabToDialog.java

示例8: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
   public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues, final TransitionValues endValues)
{
       final Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
       if (changeBounds == null)
	{
		return null;
	}

       TimeInterpolator interpolator = getInterpolator();
       if (interpolator == null) 
	{
           interpolator = AnimUtils.getFastOutSlowInInterpolator(sceneRoot.getContext());
       }

       final MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
       endValues.view.setBackground(background);

       final Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
       final Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

       if (endValues.view instanceof ViewGroup)
	{
           final ViewGroup vg = (ViewGroup)endValues.view;
           final long duration = getDuration() / 2;
           float offset = vg.getHeight() / 3;
           for (int i = 0; i < vg.getChildCount(); i++)
		{
			View v = vg.getChildAt(i);
               v.setTranslationY(offset);
               v.setAlpha(0f);
               v.animate().alpha(1f).translationY(0f).setDuration(duration).setStartDelay(duration).setInterpolator(interpolator);
               offset *= 1.8f;
           }
       }

       final AnimatorSet transition = new AnimatorSet();
       transition.playTogether(changeBounds, corners, color);
       transition.setDuration(getDuration());
       transition.setInterpolator(interpolator);
       
	return transition;
   }
 
開發者ID:MSay2,項目名稱:Mire,代碼行數:44,代碼來源:MorphTransform.java

示例9: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in))
                    .start();
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}
 
開發者ID:li-yu,項目名稱:Huahui-Android,代碼行數:45,代碼來源:MorphFabToDialog.java


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