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


Java ArgbEvaluator類代碼示例

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


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

示例1: onCreate

import android.animation.ArgbEvaluator; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    evaluator = new ArgbEvaluator();
    currentOverlayColor = ContextCompat.getColor(this, R.color.galleryCurrentItemOverlay);
    overlayColor = ContextCompat.getColor(this, R.color.galleryItemOverlay);

    Gallery gallery = Gallery.get();
    List<Image> data = gallery.getData();
    DiscreteScrollView itemPicker = (DiscreteScrollView) findViewById(R.id.item_picker);
    itemPicker.setAdapter(new GalleryAdapter(data));
    itemPicker.addScrollListener(this);
    itemPicker.addOnItemChangedListener(this);
    itemPicker.scrollToPosition(1);

    findViewById(R.id.home).setOnClickListener(this);
    findViewById(R.id.fab_share).setOnClickListener(this);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:GalleryActivity.java

示例2: setColor

import android.animation.ArgbEvaluator; //導入依賴的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

示例3: onDrawState

import android.animation.ArgbEvaluator; //導入依賴的package包/類
@Override
public void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
    canvas.drawText(title,
            (rv.getMeasuredWidth() >> 1),
            (rv.getMeasuredHeight() >> 1),
            textPaint);

    // Setup animator, if necessary
    if (anim == null) {
        this.anim = ObjectAnimator.ofObject(textPaint, "color", new ArgbEvaluator(),
                Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
        this.anim.setDuration(900);
        this.anim.setRepeatMode(ValueAnimator.REVERSE);
        this.anim.setRepeatCount(ValueAnimator.INFINITE);
        this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                rv.invalidate();
            }
        });
        this.anim.start();
    }
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:24,代碼來源:DefaultLoadingState.java

示例4: onDrawState

import android.animation.ArgbEvaluator; //導入依賴的package包/類
@Override
public final void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
    final int width = rv.getMeasuredWidth();
    final int height = rv.getMeasuredHeight();

    // Draw all of our content items
    renderContent(numberOfContentItems, width, height, canvas, contentPaint);

    // Setup and start animation, if possible
    if (animateContentItems) {
        if (anim == null) {
            this.anim = ObjectAnimator.ofObject(contentPaint, "color", new ArgbEvaluator(),
                    Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
            onInterceptAnimatorCreation(anim);
            this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    rv.invalidate();
                }
            });
            this.anim.start();
        }
    }
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:25,代碼來源:ContentItemLoadingStateFactory.java

示例5: startAnim

import android.animation.ArgbEvaluator; //導入依賴的package包/類
/**
 * 給背景設置一個動畫
 *
 * @param endProgress 動畫的結束進度
 * @param endCallback 動畫結束時觸發
 */
private void startAnim(float endProgress, final Runnable endCallback) {
    // 獲取一個最終的顏色
    int finalColor = Resource.Color.WHITE; // UiCompat.getColor(getResources(), R.color.white);
    // 運算當前進度的顏色
    ArgbEvaluator evaluator = new ArgbEvaluator();
    int endColor = (int) evaluator.evaluate(endProgress, mBgDrawable.getColor(), finalColor);
    // 構建一個屬性動畫
    ValueAnimator valueAnimator = ObjectAnimator.ofObject(this, property, evaluator, endColor);
    valueAnimator.setDuration(1500); // 時間
    valueAnimator.setIntValues(mBgDrawable.getColor(), endColor); // 開始結束值
    valueAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            // 結束時觸發
            endCallback.run();
        }
    });
    valueAnimator.start();
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:27,代碼來源:LaunchActivity.java

示例6: animateColorChange

import android.animation.ArgbEvaluator; //導入依賴的package包/類
/**
 * Change card color. This method wraps the Property Animation API mentioned here
 * https://stackoverflow.com/a/14467625/7009268
 */
public void animateColorChange(int colorFromId, int colorToId) {
    int colorFrom = ContextCompat.getColor(getContext(), colorFromId);
    int colorTo = ContextCompat.getColor(getContext(), colorToId);
    final SetGameCardView card = this;

    int duration = getContext().getResources().getInteger(R.integer.card_animation_duration);

    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(duration); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            card.setCardBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
}
 
開發者ID:jaysondc,項目名稱:TripleTap,代碼行數:22,代碼來源:SetGameCardView.java

示例7: setBackgroundColor

import android.animation.ArgbEvaluator; //導入依賴的package包/類
public void setBackgroundColor(int color, boolean animated){

        if (animated) {
            int colorFrom = ((ColorDrawable)cfDialogBackground.getBackground()).getColor();
            int colorTo = color;
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
            colorAnimation.setDuration(getContext().getResources().getInteger(R.integer.cfdialog_animation_duration)); // milliseconds
            colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animator) {
                    cfDialogBackground.setBackgroundColor((int) animator.getAnimatedValue());
                }

            });
            colorAnimation.start();
        }
        else {
            cfDialogBackground.setBackgroundColor(color);
        }
    }
 
開發者ID:Codigami,項目名稱:CFAlertDialog,代碼行數:22,代碼來源:CFAlertDialog.java

示例8: setDialogBackgroundColor

import android.animation.ArgbEvaluator; //導入依賴的package包/類
public void setDialogBackgroundColor(int color, boolean animated) {
    if (animated) {
        int colorFrom = ((ColorDrawable)dialogCardView.getBackground()).getColor();
        int colorTo = color;
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        colorAnimation.setDuration(getContext().getResources().getInteger(R.integer.cfdialog_animation_duration)); // milliseconds
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                dialogCardView.setBackgroundColor((int) animator.getAnimatedValue());
            }

        });
        colorAnimation.start();
    }
    else {
        dialogCardView.setBackgroundColor(color);
    }
}
 
開發者ID:Codigami,項目名稱:CFAlertDialog,代碼行數:21,代碼來源:CFAlertDialog.java

示例9: recolorBackground

import android.animation.ArgbEvaluator; //導入依賴的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

示例10: changeBackGroundColor

import android.animation.ArgbEvaluator; //導入依賴的package包/類
private void changeBackGroundColor() {
    int colorTo;
    int colorFrom;
    if (fullScreenMode) {
        colorFrom = getResources().getColor(R.color.bg);
        colorTo = (ContextCompat.getColor(this, R.color.bg1));
    } else {
        colorFrom = (ContextCompat.getColor(this, R.color.bg1));
        colorTo = getResources().getColor(R.color.bg);
    }
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(240);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            ActivityBackground.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:21,代碼來源:ScanImageviewActivity.java

示例11: sunsetAnimator

import android.animation.ArgbEvaluator; //導入依賴的package包/類
private void sunsetAnimator() {
    float sunYStart = mSunView.getTop();
    float sunYEnd = mSkyView.getHeight();

    ObjectAnimator heightAnimator = ObjectAnimator.ofFloat(mSunView, "y", sunYStart, sunYEnd)
            .setDuration(3000);

    ObjectAnimator sunsetSkyAnimator = ObjectAnimator.ofInt(mSkyView, "backgroundColor",
            mBlueSkyColor, mSunsetSkyColor)
            .setDuration(3000);
    ObjectAnimator nightSkyAnimator = ObjectAnimator.ofInt(mSkyView, "backgroundColor",
            mSunsetSkyColor, mNightSkyColor)
            .setDuration(1500);

    heightAnimator.setInterpolator(new AccelerateInterpolator());
    sunsetSkyAnimator.setEvaluator(new ArgbEvaluator());
    nightSkyAnimator.setEvaluator(new ArgbEvaluator());

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(heightAnimator).with(sunsetSkyAnimator).before(nightSkyAnimator);
    animatorSet.start();
}
 
開發者ID:ivicel,項目名稱:Android-Programming-BigNerd,代碼行數:23,代碼來源:SunsetFragment.java

示例12: sunriseAnimator

import android.animation.ArgbEvaluator; //導入依賴的package包/類
private void sunriseAnimator() {
    float sunriseYStart = mSkyView.getHeight();
    float sunriseYEnd = mSunView.getTop();
    
    ObjectAnimator heightAnimator = ObjectAnimator.ofFloat(mSunView, "y",
            sunriseYStart, sunriseYEnd)
            .setDuration(3000);
    ObjectAnimator sunriseSkyAnimator = ObjectAnimator.ofInt(mSkyView, "backgroundColor",
            mSunsetSkyColor, mBlueSkyColor)
            .setDuration(3000);
    ObjectAnimator daySkyAnimator = ObjectAnimator.ofInt(mSkyView, "backgroundColor",
            mNightSkyColor, mSunsetSkyColor)
            .setDuration(3000);
    
    heightAnimator.setInterpolator(new AccelerateInterpolator());
    sunriseSkyAnimator.setEvaluator(new ArgbEvaluator());
    daySkyAnimator.setEvaluator(new ArgbEvaluator());

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(daySkyAnimator).before(sunriseSkyAnimator).before(heightAnimator)
            ;
    animatorSet.start();
}
 
開發者ID:ivicel,項目名稱:Android-Programming-BigNerd,代碼行數:24,代碼來源:SunsetFragment.java

示例13: startIncertitudeAnimator

import android.animation.ArgbEvaluator; //導入依賴的package包/類
private void startIncertitudeAnimator() {
    if (mColorAnimator == null) {
        mColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mProgressColor, SkinHelper.getTranColor(mProgressColor, 0x10));
        mColorAnimator.setInterpolator(new LinearInterpolator());
        mColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                drawColor = (int) animation.getAnimatedValue();//之後就可以得到動畫的顏色了.
                postInvalidate();
            }
        });
        mColorAnimator.setDuration(1000);
        mColorAnimator.setRepeatCount(ValueAnimator.INFINITE);
        mColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
    }
    mColorAnimator.start();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:18,代碼來源:SimpleProgressBar.java

示例14: onPageScrolled

import android.animation.ArgbEvaluator; //導入依賴的package包/類
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    this.position = position;
    ArgbEvaluator evaluator = new ArgbEvaluator(); // ARGB求值器
    int evaluate = colors[0]; // 初始默認顏色(透明白)
    int startColor =  colors[this.position <= 0 ? 0 : position];
    int endColor;
    if (position == 0){
        endColor = colors[position +1];
    }else {
        endColor = colors[position +1 >=colors.length ? colors.length -1 : position +1];
    }

    evaluate = (Integer) evaluator.evaluate(positionOffset, startColor, endColor); // 根據positionOffset和第0頁~第1頁的顏色轉換範圍取顏色值
    mViewRoot.setBackgroundColor(evaluate);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(evaluate);
    }

}
 
開發者ID:wl386123298,項目名稱:ViewPagerZoomTransformer,代碼行數:21,代碼來源:WatchDetailActivity.java

示例15: run

import android.animation.ArgbEvaluator; //導入依賴的package包/類
@Override
public void run() {
    long currentTime = SystemClock.uptimeMillis();
    long delta = currentTime - lastTime;

    totalDelta += delta;
    float totalPercentage = totalDelta / ((float) speed);
    totalPercentage = totalPercentage > 1 ? 1 : totalPercentage;

    for (int colorIndex = 0; colorIndex < currentColors.length; colorIndex++) {
        currentColors[colorIndex] = (int) (new ArgbEvaluator().evaluate(totalPercentage, colors[(currentGradient + colorIndex) % colors.length], colors[(currentGradient + (colorIndex + 1)) % colors.length]));
    }

    if (totalPercentage == 1) {
        totalDelta = 0;
        currentGradient = (currentGradient + 1) % colors.length;
    }

    Shader shader = new LinearGradient(gradientsPositions[0].x, gradientsPositions[0].y, gradientsPositions[1].x, gradientsPositions[1].y, currentColors, null, Shader.TileMode.CLAMP);
    textView.getPaint().setShader(shader);

    textView.postInvalidate();
    lastTime = currentTime;
}
 
開發者ID:Mursaat,項目名稱:AnimatedGradientTextView,代碼行數:25,代碼來源:GradientRunnable.java


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