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


Java ColorUtils.setAlphaComponent方法代碼示例

本文整理匯總了Java中android.support.v4.graphics.ColorUtils.setAlphaComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorUtils.setAlphaComponent方法的具體用法?Java ColorUtils.setAlphaComponent怎麽用?Java ColorUtils.setAlphaComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.graphics.ColorUtils的用法示例。


在下文中一共展示了ColorUtils.setAlphaComponent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateColor

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
/**
 * The line's color will be:
 * - mostly opaque white if the hotseat is white (ignoring alpha)
 * - mostly opaque black if the hotseat is black (ignoring alpha)
 */
public void updateColor(ExtractedColors extractedColors) {
    int originalLineAlpha = mLinePaint.getAlpha();
    int color = extractedColors.getColor(ExtractedColors.HOTSEAT_INDEX, Color.TRANSPARENT);
    if (color != Color.TRANSPARENT) {
        color = ColorUtils.setAlphaComponent(color, 255);
        if (color == Color.BLACK) {
            mActiveAlpha = BLACK_ALPHA;
        } else if (color == Color.WHITE) {
            mActiveAlpha = WHITE_ALPHA;
        } else {
            Log.e(TAG, "Setting workspace page indicators to an unsupported color: #"
                    + Integer.toHexString(color));
        }
        mLinePaint.setColor(color);
        mLinePaint.setAlpha(originalLineAlpha);
    }
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:23,代碼來源:PageIndicatorLineCaret.java

示例2: updateHotseatPalette

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
/**
 * The hotseat's color is defined as follows:
 * - 12% black for super light wallpaper
 * - 18% white for super dark
 * - 25% white otherwise
 */
void updateHotseatPalette(Palette hotseatPalette) {
    int hotseatColor;
    int vibrantColor;

    if (hotseatPalette != null) {

        int extractedVibrantColor = hotseatPalette.getVibrantColor(ExtractedColors.DEFAULT_COLOR);
        if (ExtractionUtils.isSuperLight(hotseatPalette)) {
            hotseatColor = ColorUtils.setAlphaComponent(Color.BLACK, (int) (0.12f * 255));
            vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.12f * 255));

        } else if (ExtractionUtils.isSuperDark(hotseatPalette)) {
            hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.18f * 255));
            vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.18f * 255));
        } else {
            hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.25f * 255));
            vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.25f * 255));
        }
        setColorAtIndex(HOTSEAT_INDEX, hotseatColor);
        setColorAtIndex(VIBRANT_INDEX, vibrantColor);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:29,代碼來源:ExtractedColors.java

示例3: setBackgroundActiveColor

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
public static void setBackgroundActiveColor(View editText, int accentColor) {
    if (editText.getBackground() == null)
        return;
    int normalColor = StyledAttributesHelper.getColor(editText.getContext(),
            R.attr.colorControlNormal, 0);
    int disabledColor = ColorUtils.setAlphaComponent(normalColor, (int) (255.f *
            StyledAttributesHelper.getFloat(editText.getContext(), android.R.attr.disabledAlpha, 1.f)));
    int[][] states = new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{-android.R.attr.state_pressed, -android.R.attr.state_focused},
            new int[]{}
    };
    int[] colors = new int[]{
            disabledColor,
            normalColor,
            accentColor
    };
    ColorStateList list = new ColorStateList(states, colors);
    editText.setBackground(new ColorFilterWorkaroundDrawable(editText.getBackground()));
    ViewCompat.setBackgroundTintList(editText, list);
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:22,代碼來源:ThemedEditText.java

示例4: shiftBrightness

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
/**
 * Darkens or lightens the color by the specified amount.
 *
 * @param color  Which color to change
 * @param amount Negative to darken, positive to lighten. Must be in range [-255, 255]
 * @return The brightness-shifted color
 */
@ColorInt
public static int shiftBrightness(@ColorInt final int color, @IntRange(from = -255, to = 255) final int amount) {
    if (amount == 0f) {
        return color;
    }

    // convert from RGB to HSL (hue/saturation/lightness)
    final float[] hsl = new float[] { 0f, 0f, 0f };
    ColorUtils.colorToHSL(color, hsl);

    // clamp the lightness to [0..1] range (0% - 100%)
    float lightness = hsl[2] + amount / 255f;
    if (lightness < 0f) {
        lightness = 0f;
    } else if (lightness > 1f) {
        lightness = 1f;
    }
    hsl[2] = lightness;

    final int a = Color.alpha(color);
    final int result = ColorUtils.HSLToColor(hsl);
    return ColorUtils.setAlphaComponent(result, a);
}
 
開發者ID:milosmns,項目名稱:silly-android,代碼行數:31,代碼來源:Coloring.java

示例5: updateTaskDescription

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
private void updateTaskDescription() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        String title = getTitle().toString();
        Drawable iconDrawable = getApplicationInfo().loadIcon(getPackageManager());
        Bitmap icon = iconDrawable instanceof BitmapDrawable ? ((BitmapDrawable) iconDrawable).getBitmap() : null;
        int colorPrimary;
        if (position < getCount()) {
            try {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position));
            } catch (Resources.NotFoundException e) {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackground(position));
            }
        } else {
            TypedValue typedValue = new TypedValue();
            TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
            colorPrimary = a.getColor(0, 0);
            a.recycle();
        }
        colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 0xFF);

        setTaskDescription(new ActivityManager.TaskDescription(title, icon, colorPrimary));
    }
}
 
開發者ID:heinrichreimer,項目名稱:material-intro,代碼行數:24,代碼來源:IntroActivity.java

示例6: createButtonShadowBitmap

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
Bitmap createButtonShadowBitmap() {
	int shadowRadius = (int) buttonElevation * 2;
	int bitmapRadius = buttonRadius + (shadowRadius / 2);
	int bitmapSize = bitmapRadius * 2;
	Bitmap shadowBitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
	shadowBitmap.eraseColor(0x0);

	int colors[] = {
			ColorUtils.setAlphaComponent(SHADOW_COLOR, SHADOW_ALPHA),
			ColorUtils.setAlphaComponent(SHADOW_COLOR, 0)
	};

	float stops[] = {
			(float) (buttonRadius - (shadowRadius / 2)) / (float) bitmapRadius,
			1f
	};

	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setShader(new RadialGradient(bitmapRadius, bitmapRadius, bitmapRadius, colors, stops, Shader.TileMode.CLAMP));

	Canvas canvas = new Canvas(shadowBitmap);
	canvas.drawRect(0, 0, bitmapSize, bitmapSize, paint);

	return shadowBitmap;
}
 
開發者ID:ShamylZakariya,項目名稱:FlyoutMenus,代碼行數:27,代碼來源:FlyoutMenuView.java

示例7: updateTaskDescription

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
private void updateTaskDescription() {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        String title = getTitle().toString();
        Drawable iconDrawable = getApplicationInfo().loadIcon(getPackageManager());
        Bitmap icon = iconDrawable instanceof BitmapDrawable ? ((BitmapDrawable) iconDrawable).getBitmap() : null;
        int colorPrimary;
        if (position < getCount()) {
            try {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position));
            } catch (Resources.NotFoundException e) {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackground(position));
            }
        }
        else {
            TypedValue typedValue = new TypedValue();
            TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
            colorPrimary = a.getColor(0, 0);
            a.recycle();
        }
        colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 0xFF);

        setTaskDescription(new ActivityManager.TaskDescription(title, icon, colorPrimary));
    }
}
 
開發者ID:PuffOpenSource,項目名稱:Puff-Android,代碼行數:25,代碼來源:IntroActivity.java

示例8: init

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
public void init() {
    accentColor = getContext().getResources().getColor(R.color.colorAccent);
    bgPaint.setStyle(Paint.Style.STROKE);
    bgPaint.setStrokeWidth(Tool.convertDpToPixel(2, getContext()));
    bgPaint.setColor(Color.GRAY);

    iconPaint.setFilterBitmap(true);
    iconPaint.setColor(Color.WHITE);
    iconPaint.setStyle(Paint.Style.FILL_AND_STROKE);

    overlay = new PorterDuffColorFilter(ColorUtils.setAlphaComponent(Color.DKGRAY, 100), PorterDuff.Mode.SRC_OVER);

    strokeWidth = Tool.convertDpToPixel(strokeWidth, getContext());

    invisibleBitmap = Tool.drawableToBitmap(getResources().getDrawable(R.drawable.ic_visibility_off_24dp));

    setWillNotDraw(false);
}
 
開發者ID:BennyKok,項目名稱:PxerStudio,代碼行數:19,代碼來源:FastBitmapView.java

示例9: init

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
private void init() {
    final TypedValue typedValue = new TypedValue();
    initUsingColorAccent(typedValue);

    mImageBackgroundColor = getColor(R.color.alter_unchecked_image_background);
    mImageCheckColor = getColor(R.color.alter_image_check_color);
    mCheckedImageOverlayColor = getColor(R.color.alter_checked_photo_overlay);
    mAlbumBackgroundColor = getColor(R.color.alter_album_background);
    mAlbumNameTextColor = getColor(R.color.alter_album_name_text_color);
    mAlbumImagesCountTextColor = getColor(R.color.alter_album_images_count_text_color);
    mFabBackgroundColorWhenPressed = ColorUtils.setAlphaComponent(mFabBackgroundColor, (int) (android.graphics.Color.alpha(mFabBackgroundColor) * 0.8f));
    mPickMode = PickMode.MULTIPLE_IMAGES;

    mPopupThemeResId = Util.getDefaultPopupTheme(mContext);
    mCaptureItemIconTintColor = mDoneFabIconTintColor = Util.getDefaultIconTintColor(mContext);

    mShouldShowCaptureMenuItem = true;

    mCheckIconTintColor = Color.WHITE;
    mVideosEnabled = false;
    mVideoLengthLimit = 0; // No limit

    mVideoThumbnailOverlayColor = getColor(R.color.alter_video_thumbnail_overlay);
    mVideoIconTintColor = Color.WHITE;
}
 
開發者ID:yazeed44,項目名稱:MultiImagePicker,代碼行數:26,代碼來源:Picker.java

示例10: generateStateBackground

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
private Drawable generateStateBackground(Theme lockTheme) {
    int normalColor = lockTheme.getPrimaryColor(getContext());
    int pressedColor = lockTheme.getDarkPrimaryColor(getContext());
    //164 -> 64% alpha
    int focusedColor = ColorUtils.setAlphaComponent(normalColor, 164);
    int disabledColor = ContextCompat.getColor(getContext(), R.color.com_auth0_lock_submit_disabled);

    final StateListDrawable buttonDrawable = new StateListDrawable();
    buttonDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, new ColorDrawable(pressedColor));
    buttonDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, new ColorDrawable(focusedColor));
    buttonDrawable.addState(new int[]{android.R.attr.state_enabled}, new ColorDrawable(normalColor));
    buttonDrawable.addState(new int[]{}, new ColorDrawable(disabledColor));

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        return new RippleDrawable(ColorStateList.valueOf(pressedColor), buttonDrawable, null);
    }
    return buttonDrawable;
}
 
開發者ID:auth0,項目名稱:Lock.Android,代碼行數:19,代碼來源:ActionButton.java

示例11: onBindHeaderColumnViewHolder

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
@Override
public void onBindHeaderColumnViewHolder(@NonNull ViewHolderImpl viewHolder, int column) {
    TestHeaderColumnViewHolder vh = (TestHeaderColumnViewHolder) viewHolder;

    vh.tvText.setText(mTableDataSource.getColumnHeaderData(column));  // skip left top header
    int color = COLORS[column % COLORS.length];

    GradientDrawable gd = new GradientDrawable(
            mIsRtl ? GradientDrawable.Orientation.RIGHT_LEFT : GradientDrawable.Orientation.LEFT_RIGHT,
            new int[]{ColorUtils.setAlphaComponent(color, 50), 0x00000000});
    gd.setCornerRadius(0f);
    vh.vGradient.setBackground(gd);
    vh.vLine.setBackgroundColor(color);
}
 
開發者ID:Cleveroad,項目名稱:AdaptiveTableLayout,代碼行數:15,代碼來源:SampleLinkedTableAdapter.java

示例12: updateColor

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
/**
 * The line's color will be:
 * - mostly opaque white if the hotseat is white (ignoring alpha)
 * - mostly opaque black if the hotseat is black (ignoring alpha)
 */
public void updateColor(ExtractedColors extractedColors) {
    int originalLineAlpha = mLinePaint.getAlpha();
    int color = extractedColors.getColor(ExtractedColors.HOTSEAT_INDEX, Color.TRANSPARENT);
    if (color != Color.TRANSPARENT) {
        color = ColorUtils.setAlphaComponent(color, 255);
        if (color == Color.BLACK) {
            mActiveAlpha = BLACK_ALPHA;
        } else if (color == Color.WHITE) {
            mActiveAlpha = WHITE_ALPHA;
        }
        mLinePaint.setColor(color);
        mLinePaint.setAlpha(originalLineAlpha);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:20,代碼來源:PageIndicatorLineCaret.java

示例13: getLighterOrDarkerVersionOfColor

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
public static int getLighterOrDarkerVersionOfColor(int color, float contrastRatio) {
    int whiteMinAlpha = ColorUtils.calculateMinimumAlpha(Color.WHITE, color, contrastRatio);
    int blackMinAlpha = ColorUtils.calculateMinimumAlpha(Color.BLACK, color, contrastRatio);
    int translucentWhiteOrBlack;
    if (whiteMinAlpha >= 0) {
        translucentWhiteOrBlack = ColorUtils.setAlphaComponent(Color.WHITE, whiteMinAlpha);
    } else if (blackMinAlpha >= 0) {
        translucentWhiteOrBlack = ColorUtils.setAlphaComponent(Color.BLACK, blackMinAlpha);
    } else {
        translucentWhiteOrBlack = Color.WHITE;
    }
    return ColorUtils.compositeColors(translucentWhiteOrBlack, color);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:IconPalette.java

示例14: Hotseat

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mLauncher = Launcher.getLauncher(context);
    mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
    mBackgroundColor = ColorUtils.setAlphaComponent(
            ThemeUtils.getAttrColor(context, android.R.attr.colorPrimary), 0);
    mBackground = new ColorDrawable(mBackgroundColor);
    setBackground(mBackground);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:10,代碼來源:Hotseat.java

示例15: updateHotseatPalette

import android.support.v4.graphics.ColorUtils; //導入方法依賴的package包/類
/**
 * The hotseat's color is defined as follows:
 * - 12% black for super light wallpaper
 * - 18% white for super dark
 * - 25% white otherwise
 */
public void updateHotseatPalette(Palette hotseatPalette) {
    int hotseatColor;
    if (hotseatPalette != null && ExtractionUtils.isSuperLight(hotseatPalette)) {
        hotseatColor = ColorUtils.setAlphaComponent(Color.BLACK, (int) (0.12f * 255));
    } else if (hotseatPalette != null && ExtractionUtils.isSuperDark(hotseatPalette)) {
        hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.18f * 255));
    } else {
        hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.25f * 255));
    }
    setColorAtIndex(HOTSEAT_INDEX, hotseatColor);
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:18,代碼來源:ExtractedColors.java


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