本文整理汇总了Java中android.graphics.Color.argb方法的典型用法代码示例。如果您正苦于以下问题:Java Color.argb方法的具体用法?Java Color.argb怎么用?Java Color.argb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Color
的用法示例。
在下文中一共展示了Color.argb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAIColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int getAIColor() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int cHour = cal.get(Calendar.HOUR_OF_DAY);
int color = Color.argb(119, 94, 94, 94);
switch (cHour) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
color = Color.argb(184, 1, 7, 61);
break;
}
return color;
}
示例2: interpolateColors
import android.graphics.Color; //导入方法依赖的package包/类
private int interpolateColors(int leftColor, int rightColor, float factor) {
factor = Math.min(Math.max(factor, 0.0f), 1.0f);
int r1 = Color.red(leftColor);
int r2 = Color.red(rightColor);
int g1 = Color.green(leftColor);
int g2 = Color.green(rightColor);
int b1 = Color.blue(leftColor);
int b2 = Color.blue(rightColor);
int r = Math.min(255, (int) (r1 + (r2 - r1) * factor));
int g = Math.min(255, (int) (g1 + (g2 - g1) * factor));
int b = Math.min(255, (int) (b1 + (b2 - b1) * factor));
return Color.argb(255, r, g, b);
}
示例3: computeCardBackgroundColor
import android.graphics.Color; //导入方法依赖的package包/类
private int computeCardBackgroundColor(String color) {
if (TextUtils.isEmpty(color)
|| (!Pattern.compile("^#[a-fA-F0-9]{6}").matcher(color).matches()
&& !Pattern.compile("^[a-fA-F0-9]{6}").matcher(color).matches())) {
return Color.argb(0, 0, 0, 0);
} else {
if (Pattern.compile("^[a-fA-F0-9]{6}").matcher(color).matches()) {
color = "#" + color;
}
int backgroundColor = Color.parseColor(color);
int red = ((backgroundColor & 0x00FF0000) >> 16);
int green = ((backgroundColor & 0x0000FF00) >> 8);
int blue = (backgroundColor & 0x000000FF);
return Color.rgb(
(int) (red + (255 - red) * 0.7),
(int) (green + (255 - green) * 0.7),
(int) (blue + (255 - blue) * 0.7));
}
}
示例4: updateView
import android.graphics.Color; //导入方法依赖的package包/类
@Override
public void updateView(@NonNull QuranSettings quranSettings) {
super.updateView(quranSettings);
boolean nightMode = quranSettings.isNightMode();
int lineColor = Color.BLACK;
final int nightModeTextBrightness = nightMode ?
quranSettings.getNightModeTextBrightness() : Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS;
if (nightMode) {
lineColor = Color.argb(nightModeTextBrightness, 255, 255, 255);
}
if (pageNumber % 2 == 0) {
leftBorder = nightMode ? BorderMode.DARK : BorderMode.LIGHT;
rightBorder = BorderMode.HIDDEN;
} else {
rightBorder = nightMode ? BorderMode.DARK : BorderMode.LIGHT;
if (QuranPageLayout.lineColor != lineColor) {
QuranPageLayout.lineColor = lineColor;
lineDrawable.getPaint().setColor(lineColor);
}
leftBorder = BorderMode.LINE;
}
updateBackground(nightMode, quranSettings);
}
示例5: changeAlpha
import android.graphics.Color; //导入方法依赖的package包/类
public static int changeAlpha(int color, float fraction) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
int alpha = (int) (Color.alpha(color) * fraction);
return Color.argb(alpha, red, green, blue);
}
示例6: darkenColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int darkenColor(int color, float factor) {
int a = Color.alpha( color );
int r = Color.red( color );
int g = Color.green( color );
int b = Color.blue( color );
return Color.argb( a,
Math.max( (int)(r * factor), 0 ),
Math.max( (int)(g * factor), 0 ),
Math.max( (int)(b * factor), 0 ) );
}
示例7: blendColors
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Blend {@code color1} and {@code color2} using the given ratio.
*
* @param ratio of which to blend. 0.0 will return {@code color1}, 0.5 will give an even blend,
* 1.0 will return {@code color2}.
*/
private static int blendColors(int color1, int color2, float ratio) {
final float inverseRatio = 1f - ratio;
float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
return Color.argb((int) a, (int) r, (int) g, (int) b);
}
示例8: getComplimentColor
import android.graphics.Color; //导入方法依赖的package包/类
/**
* 从颜色得到另一个对比度高的颜色,其实就是给出黑白两种色,
* 不过传入的颜色如果较暗,那就是白色,如果较亮那就是黑色
* @param color
* @return
*/
public static int getComplimentColor(@ColorInt int color) {
// get existing colors
int alpha = Color.alpha(color);
int red = Color.red(color);
int blue = Color.blue(color);
int green = Color.green(color);
// find compliments
red = (~red) & 0xff;
blue = (~blue) & 0xff;
green = (~green) & 0xff;
return Color.argb(alpha, red, green, blue);
}
示例9: makePaint
import android.graphics.Color; //导入方法依赖的package包/类
private static Paint makePaint(Option option, Interval interval, int strokeWidth) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
// 1d and 7d invisible until a nice way to display/configure is found
int alpha;
switch (interval) {
case D1:
alpha = 0;
break;
case D7:
alpha = 0;
break;
case D30:
alpha = 200;
break;
default:
throw new IllegalArgumentException();
}
paint.setStrokeWidth(strokeWidth);
int color;
switch (option) {
case SW:
color = Color.argb(alpha, 255, 0, 0);
break;
case BU:
color = Color.argb(alpha, 0, 0, 255);
break;
default:
throw new IllegalArgumentException();
}
paint.setColor(color);
return paint;
}
示例10: updateCategoryColors
import android.graphics.Color; //导入方法依赖的package包/类
protected void updateCategoryColors(BlocklyCategory curCategory) {
Integer maybeColor = curCategory == null ? null : curCategory.getColor();
int bgColor = DEFAULT_CATEGORIES_BACKGROUND_COLOR;
if (maybeColor != null) {
bgColor = getBackgroundColor(maybeColor);
}
int alphaBgColor = Color.argb(
mCloseable ? DEFAULT_CATEGORIES_BACKGROUND_ALPHA : ColorUtils.ALPHA_OPAQUE,
Color.red(bgColor), Color.green(bgColor), Color.blue(bgColor));
this.setBackgroundColor(alphaBgColor);
}
示例11: BezelImageView
import android.graphics.Color; //导入方法依赖的package包/类
public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Attribute initialization
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, R.style.BezelImageView);
mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_biv_maskDrawable);
if (mMaskDrawable != null) {
mMaskDrawable.setCallback(this);
}
mDrawCircularShadow = a.getBoolean(R.styleable.BezelImageView_biv_drawCircularShadow, true);
mSelectorColor = a.getColor(R.styleable.BezelImageView_biv_selectorOnPress, 0);
a.recycle();
// Other initialization
mBlackPaint = new Paint();
mBlackPaint.setColor(0xff000000);
mMaskedPaint = new Paint();
mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
// Always want a cache allocated.
mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
// Create a desaturate color filter for pressed state.
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
//create a selectorFilter if we already have a color
if (mSelectorColor != 0) {
this.mSelectorFilter = new PorterDuffColorFilter(Color.argb(mSelectorAlpha, Color.red(mSelectorColor), Color.green(mSelectorColor), Color.blue(mSelectorColor)), PorterDuff.Mode.SRC_ATOP);
}
}
示例12: compositeColors
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Composite two potentially translucent colors over each other and returns the result.
*/
public static int compositeColors(int fg, int bg) {
final float alpha1 = Color.alpha(fg) / 255f;
final float alpha2 = Color.alpha(bg) / 255f;
float a = (alpha1 + alpha2) * (1f - alpha1);
float r = (Color.red(fg) * alpha1) + (Color.red(bg) * alpha2 * (1f - alpha1));
float g = (Color.green(fg) * alpha1) + (Color.green(bg) * alpha2 * (1f - alpha1));
float b = (Color.blue(fg) * alpha1) + (Color.blue(bg) * alpha2 * (1f - alpha1));
return Color.argb((int) a, (int) r, (int) g, (int) b);
}
示例13: onPageScrolled
import android.graphics.Color; //导入方法依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (positionOffset == 0 && positionOffsetPixels == 0) {
onPageSelected(position);
return;
}
boolean lessThanHalf = positionOffset < 0.5;
// alpha变化范围:-255~255
float alpha = (1 - positionOffset * 2) * 255;
int alphaWhite = Color.argb((int) alpha, 255, 255, 255); // 白渐变到透明
int alphaBlue = Color.argb((int) alpha, 0, 153, 204); // 蓝渐变到透明
int alphaWhiteReverse = Color.argb((int) -alpha, 255, 255, 255); // 白渐变到透明
int alphaBlueReverse = Color.argb((int) -alpha, 0, 153, 204); // 蓝渐变到透明
//获取滑块的Layout
mParams = (FrameLayout.LayoutParams) mViewIndicator.getLayoutParams();
//判断滑动的距离
if (positionOffset == 0) { // 停止滚动
mParams.setMargins(mViewIndicator.getWidth() * position, 0, 0, 0);
} else {
mParams.setMargins((int) (mViewIndicator.getWidth() * (position + positionOffset)), 0, 0, 0);
}
//通过LayoutParams设置滑块的位置
mViewIndicator.setLayoutParams(mParams);
switch (position) {
case 0:
if (lessThanHalf) {
mTvHotMovie.setTextColor(alphaBlue);
mTvWaitMovie.setTextColor(alphaWhite);
} else {
mTvHotMovie.setTextColor(alphaWhiteReverse);
mTvWaitMovie.setTextColor(alphaBlueReverse);
}
break;
case 1:
if (lessThanHalf) {
mTvWaitMovie.setTextColor(alphaBlue);
mTvFindMovie.setTextColor(alphaWhite);
} else {
mTvWaitMovie.setTextColor(alphaWhiteReverse);
mTvFindMovie.setTextColor(alphaBlueReverse);
}
break;
}
}
示例14: setOkColor
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Set the text color of the OK button
* @param color the color you want
*/
@SuppressWarnings("unused")
public void setOkColor(@ColorInt int color) {
mOkColor = Color.argb(255, Color.red(color), Color.green(color), Color.blue(color));
}
示例15: setColorAlpha
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Set the alpha value of the {@code color} to be the given {@code alpha} value.
*/
private static int setColorAlpha(int color, byte alpha) {
return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}