当前位置: 首页>>代码示例>>Java>>正文


Java ArgbEvaluator.evaluate方法代码示例

本文整理汇总了Java中android.animation.ArgbEvaluator.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java ArgbEvaluator.evaluate方法的具体用法?Java ArgbEvaluator.evaluate怎么用?Java ArgbEvaluator.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.animation.ArgbEvaluator的用法示例。


在下文中一共展示了ArgbEvaluator.evaluate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: updateColor

import android.animation.ArgbEvaluator; //导入方法依赖的package包/类
private void updateColor(@NonNull ArgbEvaluator colorEvaluator) {
	float fraction;
	int colorFrom;
	int colorTo;
	if (colorIntermediate != -1) {
		colorFrom = alpha <= 0f ? colorMore : colorIntermediate;
		colorTo = alpha <= 0f ? colorIntermediate : colorLess;
		fraction = alpha <= 0 ? (1 + alpha / 45f) : alpha / 45f;
	} else {
		colorFrom = colorMore;
		colorTo = colorLess;
		fraction = (alpha + 45f) / 90f;
	}
	color = (int) colorEvaluator.evaluate(fraction, colorFrom, colorTo);
	paint.setColor(color);
}
 
开发者ID:zagum,项目名称:Android-ExpandIcon,代码行数:17,代码来源:ExpandIconView.java

示例4: updateColor

import android.animation.ArgbEvaluator; //导入方法依赖的package包/类
private void updateColor(ArgbEvaluator colorEvaluator) {
	float fraction;
	int colorFrom;
	int colorTo;
	if (colorIntermediate != -1) {
		colorFrom = alpha <= 0f ? colorMore : colorIntermediate;
		colorTo = alpha <= 0f ? colorIntermediate : colorLess;
		fraction = alpha <= 0 ? (1 + alpha / 45f) : alpha / 45f;
	} else {
		colorFrom = colorMore;
		colorTo = colorLess;
		fraction = (alpha + 45f) / 90f;
	}
	color = (int) colorEvaluator.evaluate(fraction, colorFrom, colorTo);
	paint.setColor(color);
}
 
开发者ID:fython,项目名称:Blackbulb,代码行数:17,代码来源:ExpandIconView.java

示例5: updateViewWithPercent

import android.animation.ArgbEvaluator; //导入方法依赖的package包/类
@Override
void updateViewWithPercent(View child, float percent) {
    super.updateViewWithPercent(child, percent);

    float newX = targetX == UNSPECIFIED_INT ? 0 : (targetX - mStartX) * percent;
    float newY = targetY == UNSPECIFIED_INT ? 0 : (targetY - mStartY) * percent;

    // set scale
    if (targetWidth != UNSPECIFIED_INT || targetHeight != UNSPECIFIED_INT) {
        float newWidth = mStartWidth + ((targetWidth - mStartWidth) * percent);
        float newHeight = mStartHeight + ((targetHeight - mStartHeight) * percent);

        child.setScaleX(newWidth / mStartWidth);
        child.setScaleY(newHeight / mStartHeight);
        // make up position for scale change
        newX -= (mStartWidth - newWidth) / 2;
        newY -= (mStartHeight - newHeight) / 2;
    }

    // set new position
    child.setTranslationX(newX);
    child.setTranslationY(newY);

    // set alpha
    if (targetAlpha != UNSPECIFIED_FLOAT) {
        child.setAlpha(mStartAlpha + (targetAlpha - mStartAlpha) * percent);
    }

    // set background color
    if (targetBackgroundColor != UNSPECIFIED_INT && mStartBackgroundColor != 0) {
        ArgbEvaluator evaluator = new ArgbEvaluator();
        int color = (int) evaluator.evaluate(percent, mStartBackgroundColor, targetBackgroundColor);
        child.setBackgroundColor(color);
    }

    // set rotation
    if (targetRotateX != UNSPECIFIED_FLOAT) {
        child.setRotationX(mStartRotateX + (targetRotateX - mStartRotateX) * percent);
    }
    if (targetRotateY != UNSPECIFIED_FLOAT) {
        child.setRotationY(mStartRotateY + (targetRotateY - mStartRotateY) * percent);
    }

    child.requestLayout();
}
 
开发者ID:zoonooz,项目名称:simple-view-behavior,代码行数:46,代码来源:SimpleViewBehavior.java


注:本文中的android.animation.ArgbEvaluator.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。