本文整理匯總了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);
}