Example usage for android.graphics Color argb

List of usage examples for android.graphics Color argb

Introduction

In this page you can find the example usage for android.graphics Color argb.

Prototype

@ColorInt
public static int argb(float alpha, float red, float green, float blue) 

Source Link

Document

Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).

Usage

From source file:am.widget.basetabstrip.BaseTabStrip.java

/**
 * ???//from   w  w w  . java  2  s . c o m
 *
 * @param normalColor   
 * @param selectedColor 
 * @param offset        ??
 * @return ??
 */
@SuppressWarnings("unused")
protected int getColor(int normalColor, int selectedColor, float offset) {
    int normalAlpha = Color.alpha(normalColor);
    int normalRed = Color.red(normalColor);
    int normalGreen = Color.green(normalColor);
    int normalBlue = Color.blue(normalColor);
    int selectedAlpha = Color.alpha(selectedColor);
    int selectedRed = Color.red(selectedColor);
    int selectedGreen = Color.green(selectedColor);
    int selectedBlue = Color.blue(selectedColor);
    int a = (int) Math.ceil((selectedAlpha - normalAlpha) * offset);
    int r = (int) Math.ceil((selectedRed - normalRed) * offset);
    int g = (int) Math.ceil((selectedGreen - normalGreen) * offset);
    int b = (int) Math.ceil((selectedBlue - normalBlue) * offset);
    return Color.argb(normalAlpha + a, normalRed + r, normalGreen + g, normalBlue + b);
}

From source file:com.customdatepicker.date.DatePickerDialog.java

/**
 * Set the text color of the OK button//from  ww w.  j  av a 2 s.com
 *
 * @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));
}

From source file:com.smp.musicspeed.MainActivity.java

private void addBarGraphRenderers() {
    Paint paint = new Paint();
    paint.setStrokeWidth(10.5f);/*  w w  w.j av  a  2 s  .c  om*/
    paint.setAntiAlias(true);
    paint.setColor(Color.argb(255, 144, 202, 249));
    BarGraphRenderer barGraphRendererBottom = new BarGraphRenderer(4, paint, false);
    visualizerView.addRenderer(barGraphRendererBottom);
}

From source file:com.customdatepicker.date.DatePickerDialog.java

/**
 * Set the text color of the Cancel button
 *
 * @param color the color you want/*from w ww.  j a  va  2  s .c  om*/
 */
@SuppressWarnings("unused")
public void setCancelColor(@ColorInt int color) {
    mCancelColor = Color.argb(255, Color.red(color), Color.green(color), Color.blue(color));
}

From source file:org.mozilla.gecko.GeckoAppShell.java

static private Bitmap getLauncherIcon(Bitmap aSource) {
    final int kOffset = 6;
    final int kRadius = 5;
    int kIconSize;
    int kOverlaySize;
    switch (getDpi()) {
    case DisplayMetrics.DENSITY_MEDIUM:
        kIconSize = 48;/*from   ww w  .ja va  2 s  .co m*/
        kOverlaySize = 32;
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        kIconSize = 96;
        kOverlaySize = 48;
        break;
    case DisplayMetrics.DENSITY_HIGH:
    default:
        kIconSize = 72;
        kOverlaySize = 32;
    }

    Bitmap bitmap = Bitmap.createBitmap(kIconSize, kIconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // draw a base color
    Paint paint = new Paint();

    if (aSource == null) {
        float[] hsv = new float[3];
        hsv[0] = 32.0f;
        hsv[1] = 1.0f;
        hsv[2] = 1.0f;
        paint.setColor(Color.HSVToColor(hsv));
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
    } else {
        int color = BitmapUtils.getDominantColor(aSource);
        paint.setColor(color);
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
        paint.setColor(Color.argb(100, 255, 255, 255));
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
    }

    // draw the overlay
    Bitmap overlay = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_bg);
    canvas.drawBitmap(overlay, null, new Rect(0, 0, kIconSize, kIconSize), null);

    // draw the bitmap
    if (aSource == null)
        aSource = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_star);

    if (aSource.getWidth() < kOverlaySize || aSource.getHeight() < kOverlaySize) {
        canvas.drawBitmap(aSource, null,
                new Rect(kIconSize / 2 - kOverlaySize / 2, kIconSize / 2 - kOverlaySize / 2,
                        kIconSize / 2 + kOverlaySize / 2, kIconSize / 2 + kOverlaySize / 2),
                null);
    } else {
        canvas.drawBitmap(aSource, null,
                new Rect(kIconSize / 2 - aSource.getWidth() / 2, kIconSize / 2 - aSource.getHeight() / 2,
                        kIconSize / 2 + aSource.getWidth() / 2, kIconSize / 2 + aSource.getHeight() / 2),
                null);
    }

    return bitmap;
}

From source file:com.customdatepicker.date.DatePickerDialog.java

/**
 * Set the accent color of this dialog//w w  w  .j  a  va  2  s .com
 *
 * @param color the accent color you want
 */
public void setAccentColor(@ColorInt int color) {
    mAccentColor = Color.argb(255, Color.red(color), Color.green(color), Color.blue(color));
}

From source file:com.doubleTwist.drawerlib.ADrawerLayout.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void adjustScrollStates(float x, float y) {
    dx = Math.round(x);/*from   w  ww  .  j  a  va  2 s .  c  om*/
    dy = Math.round(y);

    if (mContent != null) {
        dxx = Math.round(dx * mContentParalaxFactorX);
        dyy = Math.round(dy * mContentParalaxFactorY);
        setDXYCompat(mContent, dxx, dyy);

        animateLeft = mAnimateScrolling[0] && mDrawerState.mActiveDrawer == LEFT_DRAWER;
        animateTop = mAnimateScrolling[1] && mDrawerState.mActiveDrawer == TOP_DRAWER;
        animateRight = mAnimateScrolling[2] && mDrawerState.mActiveDrawer == RIGHT_DRAWER;
        animateBottom = mAnimateScrolling[3] && mDrawerState.mActiveDrawer == BOTTOM_DRAWER;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            if (animateLeft)
                aparams = mAnimationParams[0];
            else if (animateTop)
                aparams = mAnimationParams[1];
            else if (animateRight)
                aparams = mAnimationParams[2];
            else if (animateBottom)
                aparams = mAnimationParams[3];
            else
                aparams = mNoAnimationParameters;

            animScale = 1 - aparams.mScale * getScrollFraction();
            animAlpha = 1 - aparams.mAlpha * getScrollFraction();
            animRotX = -90.f * aparams.mRotX * getScrollFraction();
            animRotY = -90.f * aparams.mRotY * getScrollFraction();
            if (mContent.getScaleX() != animScale)
                mContent.setScaleX(animScale);
            if (mContent.getScaleY() != animScale)
                mContent.setScaleY(animScale);
            if (mContent.getAlpha() != animAlpha)
                mContent.setAlpha(animAlpha);
            if (mContent.getRotationY() != animRotY)
                mContent.setRotationY(animRotY);
            if (mContent.getRotationX() != animRotX)
                mContent.setRotationX(animRotX);
        }
    }

    if (mContentDimmer != null) {
        dimLeft = mDimContent[0] && mDrawerState.mActiveDrawer == LEFT_DRAWER;
        dimTop = mDimContent[1] && mDrawerState.mActiveDrawer == TOP_DRAWER;
        dimRight = mDimContent[2] && mDrawerState.mActiveDrawer == RIGHT_DRAWER;
        dimBottom = mDimContent[3] && mDrawerState.mActiveDrawer == BOTTOM_DRAWER;

        // dxx = Math.round(dx);
        // if( mDrawerState.mActiveDrawer == LEFT_DRAWER ) dxx += mPeekSize.left;
        // if( mDrawerState.mActiveDrawer == RIGHT_DRAWER ) dxx -= mPeekSize.right;
        // dyy = Math.round(dy);
        // if( mDrawerState.mActiveDrawer == TOP_DRAWER ) dyy += mPeekSize.top;
        // if( mDrawerState.mActiveDrawer == BOTTOM_DRAWER ) dyy -= mPeekSize.bottom;

        if (isClosed() || dimLeft || dimTop || dimRight || dimBottom) {
            // dxx = Math.round(dx * mContentParalaxFactorX);
            // dyy = Math.round(dy * mContentParalaxFactorY);
            dxx = dx;
            dyy = dy;
            if (mPeekSize != null) {
                if (dimLeft)
                    dxx += mPeekSize.left;
                if (dimRight)
                    dxx -= mPeekSize.right;
                if (dimTop)
                    dyy += mPeekSize.top;
                if (dimBottom)
                    dyy -= mPeekSize.bottom;
            }
            setDXYCompat(mContentDimmer, dxx, dyy);

            alpha = getScrollFraction();
            alpha = Math.min(1.f, Math.max(0.f, alpha));
            mContentDimmer.setBackgroundColor(Color.argb(Math.round(alpha * Color.alpha(mDimmingColor)),
                    Color.red(mDimmingColor), Color.green(mDimmingColor), Color.blue(mDimmingColor)));
        }
    }

    if (mLeft != null) {
        dxx = -mLeft.getMeasuredWidth() + Math.max(0, dx);
        dyy = dy;
        setDXYCompat(mLeft, dxx, dyy);
    }

    if (mRight != null) {
        dxx = mRight.getMeasuredWidth() + Math.min(0, dx);
        dyy = dy;
        setDXYCompat(mRight, dxx, dyy);
    }

    if (mTop != null) {
        dxx = dx;
        dyy = -mTop.getMeasuredHeight() + Math.max(0, dy);
        setDXYCompat(mTop, dxx, dyy);
    }

    if (mBottom != null) {
        dxx = dx;
        dyy = mBottom.getMeasuredHeight() + Math.min(0, dy);
        setDXYCompat(mBottom, dxx, dyy);
    }
}

From source file:com.upsideideas.zdrawerlayout.ADrawerLayout.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void adjustScrollStates(float x, float y) {
    dx = Math.round(x);//  w  ww.  java2  s .  c om
    dy = Math.round(y);

    if (mContent != null) {
        dxx = Math.round(dx * mContentParalaxFactorX);
        dyy = Math.round(dy * mContentParalaxFactorY);
        setDXYCompat(mContent, dxx, dyy);

        animateLeft = mAnimateScrolling[0] && mDrawerState.mActiveDrawer == LEFT_DRAWER;
        animateTop = mAnimateScrolling[1] && mDrawerState.mActiveDrawer == TOP_DRAWER;
        animateRight = mAnimateScrolling[2] && mDrawerState.mActiveDrawer == RIGHT_DRAWER;
        animateBottom = mAnimateScrolling[3] && mDrawerState.mActiveDrawer == BOTTOM_DRAWER;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            if (animateLeft)
                aparams = mAnimationParams[0];
            else if (animateTop)
                aparams = mAnimationParams[1];
            else if (animateRight)
                aparams = mAnimationParams[2];
            else if (animateBottom)
                aparams = mAnimationParams[3];
            else
                aparams = mNoAnimationParameters;

            animScale = 1 - aparams.mScale * getScrollFraction();
            animAlpha = 1 - aparams.mAlpha * getScrollFraction();
            animRotX = -90.f * aparams.mRotX * getScrollFraction();
            animRotY = -90.f * aparams.mRotY * getScrollFraction();
            if (mContent.getScaleX() != animScale)
                mContent.setScaleX(animScale);
            if (mContent.getScaleY() != animScale)
                mContent.setScaleY(animScale);
            if (mContent.getAlpha() != animAlpha)
                mContent.setAlpha(animAlpha);
            if (mContent.getRotationY() != animRotY)
                mContent.setRotationY(animRotY);
            if (mContent.getRotationX() != animRotX)
                mContent.setRotationX(animRotX);
        }
    }

    if (mContentDimmer != null) {
        dimLeft = mDimContent[0] && mDrawerState.mActiveDrawer == LEFT_DRAWER;
        dimTop = mDimContent[1] && mDrawerState.mActiveDrawer == TOP_DRAWER;
        dimRight = mDimContent[2] && mDrawerState.mActiveDrawer == RIGHT_DRAWER;
        dimBottom = mDimContent[3] && mDrawerState.mActiveDrawer == BOTTOM_DRAWER;

        // dxx = Math.round(dx);
        // if( mDrawerState.mActiveDrawer == LEFT_DRAWER ) dxx += mPeekSize.left;
        // if( mDrawerState.mActiveDrawer == RIGHT_DRAWER ) dxx -= mPeekSize.right;
        // dyy = Math.round(dy);
        // if( mDrawerState.mActiveDrawer == TOP_DRAWER ) dyy += mPeekSize.top;
        // if( mDrawerState.mActiveDrawer == BOTTOM_DRAWER ) dyy -= mPeekSize.bottom;

        if (isClosed() || dimLeft || dimTop || dimRight || dimBottom) {
            // dxx = Math.round(dx * mContentParalaxFactorX);
            // dyy = Math.round(dy * mContentParalaxFactorY);
            dxx = dx;
            dyy = dy;
            if (mPeekSize != null) {
                if (dimLeft)
                    dxx += mPeekSize.left;
                if (dimRight)
                    dxx -= mPeekSize.right;
                if (dimTop)
                    dyy += mPeekSize.top;
                if (dimBottom)
                    dyy -= mPeekSize.bottom;
            }
            setDXYCompat(mContentDimmer, dxx, dyy);

            alpha = getScrollFraction();
            alpha = Math.min(1.f, Math.max(0.f, alpha));
            mContentDimmer.setBackgroundColor(Color.argb(Math.round(alpha * Color.alpha(mDimmingColor)),
                    Color.red(mDimmingColor), Color.green(mDimmingColor), Color.blue(mDimmingColor)));
        }
    }

    if (mLeft != null) {
        dxx = -mLeft.getMeasuredWidth() + Math.max(0, dx);
        dyy = dy;
        setDXYCompat(mLeft, dxx, dyy);
    }

    if (mRight != null) {
        dxx = mRight.getMeasuredWidth() + Math.min(0, dx);
        dyy = dy;
        setDXYCompat(mRight, dxx, dyy);
    }

    if (mTop != null) {
        dxx = dx;
        dyy = -mTop.getMeasuredHeight() + Math.max(0, dy);
        setDXYCompat(mTop, dxx, dyy);
    }

    if (mBottom != null) {
        dxx = dx;
        dyy = mBottom.getMeasuredHeight() + Math.min(0, dy);
        setDXYCompat(mBottom, dxx, dyy);
    }
}

From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java

public void setTextColor(int textColor) {
    setSelectedTextColor(textColor);/*from  ww  w .  j a  va2 s .c o  m*/
    setTextColor(getColorStateList(
            Color.argb(textAlpha, Color.red(textColor), Color.green(textColor), Color.blue(textColor))));
}

From source file:com.app.viaje.viaje.MapsActivity.java

/**
 * @description :: Creates the circle in the map
 * @param location/*from  w  w w .j  a  v a 2 s .c  o m*/
 * @return
 */
private CircleOptions drawCircle(LatLng location) {

    CircleOptions options = new CircleOptions();

    options.center(location);
    options.radius(1600);
    options.fillColor(Color.argb(10, 0, R.color.app_color, 0));
    options.strokeColor(ContextCompat.getColor(getApplicationContext(), R.color.stroke_color));
    options.strokeWidth(5);

    return options;
}