Java Code Examples for android.graphics.Color.parseColor()

The following are Jave code examples for showing how to use parseColor() of the android.graphics.Color class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: FindX   File: AboutDevelopers.java   View Source Code Vote up 6 votes
void open()
{
    ColorDrawable[] color = {new ColorDrawable(Color.parseColor("#00ffffff")), new ColorDrawable(Color.parseColor("#CC000000"))};
    TransitionDrawable trans = new TransitionDrawable(color);
    //This will work also on old devices. The latest API says you have to use setBackground instead.
    rel.setBackgroundDrawable(trans);
    trans.startTransition(100);


    //rel.setBackgroundColor(Color.parseColor("#CC000000"));
    web.setVisibility(View.VISIBLE);
    fb.setVisibility(View.VISIBLE);
    email.setVisibility(View.VISIBLE);
    webtxt.setVisibility(View.VISIBLE);
    fbtxt.setVisibility(View.VISIBLE);
    emailtxt.setVisibility(View.VISIBLE);

}
 
Example 2
Project: ChatExchange-old   File: SpotlightConfig.java   View Source Code Vote up 6 votes
public SpotlightConfig() {
    this.maskColor = 0x70000000;
    this.introAnimationDuration = 400;
    this.isRevealAnimationEnabled = true;
    this.fadingTextDuration = 400;
    this.padding = 20;
    this.dismissOnTouch = true;
    this.dismissOnBackpress=true;
    this.isPerformClick = true;
    this.headingTvSize = 24;
    this.headingTvSizeDimenUnit = -1;
    this.headingTvColor = Color.parseColor("#eb273f");
    this.headingTvText = "Hello";
    this.subHeadingTvSize = 24;
    this.subHeadingTvSizeDimenUnit = -1;
    this.subHeadingTvColor = Color.parseColor("#ffffff");
    this.subHeadingTvText = "Hello";
    this.lineAnimationDuration = 300;
    this.lineStroke = Utils.dpToPx(4);
    this.lineAndArcColor = Color.parseColor("#eb273f");
    this.showTargetArc = true;
}
 
Example 3
Project: phonk   File: PCanvas.java   View Source Code Vote up 5 votes
@ProtoMethod(description = "Create a linear shader", example = "")
@ProtoMethodParam(params = {"x1", "y1", "x2", "y2", "colorHex1", "colorHex2", "tileMode"})
public Shader linearShader(float x1, float y1, float x2, float y2, String c1, String c2) {
    Shader.TileMode mode = Shader.TileMode.REPEAT;

    Shader shader = new LinearGradient(x1, y1, x2, y2, Color.parseColor(c1), Color.parseColor(c2), mode);
    return shader;
}
 
Example 4
Project: aarLibrary   File: Toasty.java   View Source Code Vote up 5 votes
public static void reset() {
    Toasty.DEFAULT_TEXT_COLOR = Color.parseColor("#FFFFFF");
    Toasty.ERROR_COLOR = Color.parseColor("#D50000");
    Toasty.INFO_COLOR = Color.parseColor("#3F51B5");
    Toasty.SUCCESS_COLOR = Color.parseColor("#388E3C");
    Toasty.WARNING_COLOR = Color.parseColor("#FFA900");
    Toasty.currentTypeface = LOADED_TOAST_TYPEFACE;
    Toasty.textSize = 16;
    Toasty.tintIcon = true;
}
 
Example 5
Project: DailyStudy   File: SpannableStringActivity.java   View Source Code Vote up 5 votes
/**
 * ForegroundColorSpan
 */
private void foreground() {
    SpannableString string = new SpannableString("设置文字的前景色为淡蓝色");
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#0099EE"));
    string.setSpan(colorSpan, 9, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    fgtext.setText(string);
}
 
Example 6
Project: filepicker   File: ImageEditLayout.java   View Source Code Vote up 5 votes
@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (ev.getX() > mStartX && ev.getX() < mIvBack.getX() - 10) {
                mIsTouchColor = true;
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (mIsTouchColor && ev.getX() > mStartX && ev.getX() < mIvBack.getX() - 10) {
                int i = (int) ((ev.getX() - mStartX) / mLength);
                mCurrentColor = Color.parseColor(colors[i]);
                mCurrentX = (int) ev.getX();
                invalidate();
            }
            break;
        case MotionEvent.ACTION_UP:
            if (mIsTouchColor) {
                int upX = (int) ev.getX();
                if (upX < mStartX) {
                    upX = mStartX;
                } else if (upX > mIvBack.getX() - 10) {
                    upX = (int) (mIvBack.getX() - 10);
                }
                doXAnim(mStartX + ((upX - mStartX) / mLength) * mLength + mLength / 2);
            }
            break;
    }
    return true;
}
 
Example 7
Project: Phoenix-for-VK   File: CurrentTheme.java   View Source Code Vote up 5 votes
public static int getColorFromAttrs(int resId, Context context, String defaultColor) {
    TypedValue a = new TypedValue();
    context.getTheme().resolveAttribute(resId, a, true);
    if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
        return a.data;
    } else {
        return Color.parseColor(defaultColor);
    }
}
 
Example 8
Project: Tangram-Android   File: SingleImageView.java   View Source Code Vote up 5 votes
public static int parseColor(String colorStr, String defaultColor) {
    try {
        return Color.parseColor(colorStr);
    } catch (Exception e) {
        return Color.parseColor(defaultColor);
    }
}
 
Example 9
Project: DialogSheet   File: Utils.java   View Source Code Vote up 5 votes
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);
}
 
Example 10
Project: ImageSaveandShare   File: UtilsLibrary.java   View Source Code Vote up 5 votes
static Drawable createButtonBackgroundDrawable(@NonNull Context context, int fillColor) {
    int buttonCornerRadius = dpToPixels(context, 2);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        TypedValue v = new TypedValue();
        boolean hasAttribute = context.getTheme().resolveAttribute(R.attr.colorControlHighlight, v, true);
        int rippleColor = hasAttribute ? v.data : Color.parseColor("#88CCCCCC");
        return createButtonBackgroundDrawableLollipop(fillColor, rippleColor, buttonCornerRadius);
    }
    return createButtonBackgroundDrawableBase(fillColor, buttonCornerRadius);
}
 
Example 11
Project: Tangram-Android   File: Style.java   View Source Code Vote up 5 votes
public static int parseColor(String colorString, int defaultColor) {
    try {
        Integer integer = colorCache.get(colorString);
        if (integer != null) {
            return integer.intValue();
        } else {
            integer = Color.parseColor(colorString);
            colorCache.put(colorString, integer);
            return integer.intValue();
        }
    } catch (Exception e) {
        return defaultColor;
    }
}
 
Example 12
Project: shareNote   File: CodeUtils.java   View Source Code Vote up 5 votes
private int randomColor() {
    mBuilder.delete(0, mBuilder.length()); //使用之前首先清空内容

    String haxString;
    for (int i = 0; i < 3; i++) {
        haxString = Integer.toHexString(mRandom.nextInt(0xFF));
        if (haxString.length() == 1) {
            haxString = "0" + haxString;
        }

        mBuilder.append(haxString);
    }

    return Color.parseColor("#" + mBuilder.toString());
}
 
Example 13
Project: ZxingForAndroid   File: ScanBoxView.java   View Source Code Vote up 5 votes
private void init(Context context) {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mMaskColor = Color.parseColor("#33FFFFFF");
    mCornerColor = Color.WHITE;
    mCornerLength = QRCodeUtil.dp2px(context, 20);
    mCornerSize = QRCodeUtil.dp2px(context, 3);
    mScanLineSize = QRCodeUtil.dp2px(context, 1);
    mScanLineColor = Color.WHITE;
    mScanLineMargin = 0;
    mIsShowDefaultScanLineDrawable = false;
    mCustomScanLineDrawable = null;
    mScanLineBitmap = null;
    mBorderSize = QRCodeUtil.dp2px(context, 1);
    mBorderColor = Color.WHITE;
    mAnimTime = 1000;
    mRectWidth = QRCodeUtil.dp2px(context, 200);
    mMoveStepDistance = QRCodeUtil.dp2px(context, 2);
    mTipText = null;
    mTipTextSize = QRCodeUtil.sp2px(context, 14);
    mTipTextColor = Color.WHITE;
    mIsTipTextBelowRect = false;
    mTipTextMargin = QRCodeUtil.dp2px(context, 20);
    mIsShowTipTextAsSingleLine = false;
    mTipBackgroundColor = Color.parseColor("#22000000");
    mIsShowTipBackground = false;
    mIsScanLineReverse = false;

    mTipPaint = new TextPaint();
    mTipPaint.setAntiAlias(true);

    mTipBackgroundRadius = QRCodeUtil.dp2px(context, 4);
}
 
Example 14
Project: LemonKit4Android   File: LKTabBarItem.java   View Source Code Vote up 5 votes
public
@ColorInt
int getSelectedColor() {
    return selectedColor != -1 ?
            selectedColor :
            belongTabBar == null ?
                    Color.parseColor("#4169E1") :
                    belongTabBar.getDefaultSelectedColor();
}
 
Example 15
Project: JD-Test   File: BottomNavigationItem.java   View Source Code Vote up 5 votes
/**
 * @param context to fetch color
 * @return in-active color (or) -1 if no color is specified
 */
protected int getInActiveColor(Context context) {
    if (this.mInActiveColorResource != 0) {
        return ContextCompat.getColor(context, mInActiveColorResource);
    } else if (!TextUtils.isEmpty(mInActiveColorCode)) {
        return Color.parseColor(mInActiveColorCode);
    } else if (this.mInActiveColor != 0) {
        return mInActiveColor;
    } else {
        return -1;
    }
}
 
Example 16
Project: CXJPadProject   File: QuickPanelPlugin.java   View Source Code Vote up 5 votes
public void onDrawerSlide(float slideOffset) {
    int alpha = Math.round(slideOffset * 0.6f * 255);
    String hex = Integer.toHexString(alpha).toUpperCase();
    if (hex.length() == 1) hex = "0" + hex;

    String colorString = "#" + hex + "000000";
    int color = Color.parseColor(colorString);
    shadowView.setBackgroundColor(color);
    if (slideOffset == 0) {
        shadowView.setVisibility(View.GONE);
    } else {
        shadowView.setVisibility(View.VISIBLE);
    }
}
 
Example 17
Project: ColorBox-library   File: PalettesFragment.java   View Source Code Vote up 4 votes
@Override
public void onResume() {
    super.onResume();
    SelectorsAdapter.mSelectedColor = Color.parseColor(Palettes.getPalette(Palettes.RED, true).second[6]);
}
 
Example 18
Project: simple-share-android   File: Utils.java   View Source Code Vote up 4 votes
public static int getStatusBarColor(int color1) {
    int color2 = Color.parseColor("#000000");
    return blendColors(color1, color2, 0.9f);
}
 
Example 19
Project: AssistantBySDK   File: TimePickerDialog.java   View Source Code Vote up 4 votes
/**
 * Set the accent color of this dialog
 * @param color the accent color you want
 */
@SuppressWarnings("unused")
public void setAccentColor(String color) {
    mAccentColor = Color.parseColor(color);
}
 
Example 20
Project: ColorBox-library   File: ColorsAdapter.java   View Source Code Vote up 3 votes
@Override
public void onBindViewHolder(SimpleViewHolder holder, int position) {

    holder.code.setText(mColors.first[holder.getAdapterPosition()]);
    holder.hex.setText(mColors.second[holder.getAdapterPosition()]);

    int color = Color.parseColor(mColors.second[holder.getAdapterPosition()]);

    int textColor = ColorBox.isColorDark(color) ? Color.WHITE : Color.BLACK;

    holder.code.setTextColor(textColor);
    holder.hex.setTextColor(textColor);

    holder.itemView.setBackgroundColor(color);
}