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


Java Color.argb方法代碼示例

本文整理匯總了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;
}
 
開發者ID:shivam301296,項目名稱:True-Weather,代碼行數:21,代碼來源:Const.java

示例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);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:19,代碼來源:ColorPicker.java

示例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));
    }
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:20,代碼來源:CollectionAdapter.java

示例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);
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:26,代碼來源:QuranPageLayout.java

示例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);
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:8,代碼來源:ThemeUtil.java

示例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 ) );
    }
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:13,代碼來源:AndroidUtils.java

示例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);
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:15,代碼來源:QMUICollapsingTextHelper.java

示例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);
}
 
開發者ID:halohoop,項目名稱:AndroidDigIn,代碼行數:21,代碼來源:Utils.java

示例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;
}
 
開發者ID:lambdasoup,項目名稱:blockvote,代碼行數:38,代碼來源:HistoryView.java

示例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);
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:13,代碼來源:CategoryView.java

示例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);
    }
}
 
開發者ID:TaRGroup,項目名稱:CoolApk-Console,代碼行數:38,代碼來源:BezelImageView.java

示例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);
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:15,代碼來源:ColorUtils.java

示例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;
    }
}
 
開發者ID:coderwjq,項目名稱:ZhaZhaShop,代碼行數:50,代碼來源:FragmentMovieMain.java

示例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));
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:9,代碼來源:DatePickerDialog.java

示例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));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:7,代碼來源:SlidingTabStrip.java


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