本文整理汇总了Java中android.support.v4.graphics.ColorUtils.blendARGB方法的典型用法代码示例。如果您正苦于以下问题:Java ColorUtils.blendARGB方法的具体用法?Java ColorUtils.blendARGB怎么用?Java ColorUtils.blendARGB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.ColorUtils
的用法示例。
在下文中一共展示了ColorUtils.blendARGB方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setButton
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
static void setButton(@ColorInt int bgColor, @ColorInt int color, Button button, boolean colored) {
if (!colored) {
if (bgColor!=-1)
color = bgColor;
else
color = Color.parseColor("#ffffff");
}
int selectedColor = isColorLight(color) ?
ColorUtils.blendARGB(color, Color.parseColor("#000000"), 0.15f) :
ColorUtils.blendARGB(color, Color.parseColor("#FFFFFF"), 0.20f);
GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
new int[]{selectedColor, selectedColor});
GradientDrawable drawable2 = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
new int[]{color, color});
drawable.setCornerRadius(dpToPx(2));
drawable2.setCornerRadius(dpToPx(2));
StateListDrawable button1bg = new StateListDrawable();
button1bg.addState(new int[] {android.R.attr.state_pressed}, drawable);
button1bg.addState(new int[] {}, drawable2);
button1bg.setExitFadeDuration(250);
button.setBackgroundDrawable(button1bg);
}
示例2: handleOverflow
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
private void handleOverflow(){
//If max images reached
if(getImageCount() >= getMaxImageCount()){
if(overflowView == null) {
overflowView = new TextImageView(getContext());
}
removeExtraViews();
updateLayoutRepresentation(getWidth(), getHeight(), getChildCount(), true);
}
//setup overflow view
if(extraImages > 0){
overflowView.setText(getResources().getString(R.string.more_images, extraImages));
int color = ColorUtils.blendARGB(moreTextColor, moreColor, 0.4f);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
RippleDrawable rippledImage = new RippleDrawable(
ColorStateList.valueOf(color), null, null);
overflowView.setForeground(rippledImage);
}else{
int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */};
TypedArray ta = getContext().obtainStyledAttributes(attrs);
Drawable drawableFromTheme = ta.getDrawable(0 /* index */);
ta.recycle();
overflowView.setForeground(drawableFromTheme);
}
overflowView.setTextColor(moreTextColor).setImageBackgroundColor(moreColor);
addClickListeners();
if(overflowView.getParent() != this) {
addView1(overflowView, lowerRightCorner.getIndex());
}
}
}
示例3: setBackgroundColor
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
private void setBackgroundColor(int currentValue) {
final float coefficient = currentValue / (float) (temperatureView.getMaxValue());
final int color = ColorUtils.blendARGB(Color.parseColor("#FF9D6E"), Color.parseColor("#6ABFFF"), coefficient);
rlRoot.setBackgroundColor(color);
}
示例4: blendUpper
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
public void blendUpper(@ColorInt int color) {
int avg = ColorUtils.blendARGB(color, getUpper(), RATIO);
pair = Pair.create(avg, getLower());
}
示例5: blendLower
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
public void blendLower(@ColorInt int color) {
int avg = ColorUtils.blendARGB(color, getLower(), RATIO);
pair = Pair.create(getUpper(), avg);
}
示例6: setColorRatio
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
public void setColorRatio(float ratio) {
mColorRatio = Math.max(0f, Math.min(ratio, 1f));
mColor = ColorUtils.blendARGB(mColorStart, mColorEnd, mColorRatio);
invalidateSelf();
}
示例7: blendColor
import android.support.v4.graphics.ColorUtils; //导入方法依赖的package包/类
/**
* Returns a blend color of 2 colors
*
* @param color1 The preferred color 1
*
* @param color2 The preferred color 2
*
* @return The blend color of color 1 & color 2
*/
private int blendColor(int color1, int color2) {
return ColorUtils.blendARGB(color1, color2, 0.8f);
}