Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

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

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:Main.java

public static int reduceColorOpacity(int color) {
    String colorHex = String.format("%06X", 0xFFFFFF & color);
    int resultColor = Color.parseColor("#55" + colorHex);
    return resultColor;
}

From source file:Main.java

public static int parseColorFromString(String color) {
    int colorInt;
    if (color != null && !color.isEmpty() && !color.substring(0, 1).equals("#")) {
        colorInt = Color.parseColor("#" + color);
    } else {//from  www.j av  a  2 s.  com
        colorInt = Color.parseColor(color);
    }
    return colorInt;
}

From source file:Main.java

private static void drawAndroidBody(Canvas canvas, Paint paint, float w, float h) {
    paint.setColor(Color.parseColor("#43A047"));
    canvas.drawRoundRect(new RectF(-w / 2, 0, w / 2, h), w / 10, w / 10, paint);
}

From source file:Main.java

public static int subjectColorInt(String subject) {
    int color = 0;
    if (subject.equals("addition")) {
        color = Color.parseColor("#7979FF");
    } else if (subject.equals("subtraction")) {
        color = Color.parseColor("#D79BFA");
    } else if (subject.equals("multiplication")) {
        color = Color.parseColor("#66b266");
    } else if (subject.equals("fractions")) {
        color = Color.parseColor("#FA96D2");
    } else if (subject.equals("division")) {
        color = Color.parseColor("#44B4D5");
    } else if (subject.equals("geometry")) {
        color = Color.parseColor("#FABB4E");
    }/*from w  w w . j a v a 2s.  co m*/
    return color;
}

From source file:Main.java

public static final int getSplashScreenColor(Context context) {
    return Color.parseColor(SPLASH_SCREEN_COLOR);
}

From source file:Main.java

public static ColorStateList getSocialButtonColorState(String color) {
    return createColorStateList("", Color.parseColor(addAlpha(color, 0.75)), Color.parseColor(color));
}

From source file:Main.java

public static SpannableString backgroundColor(SpannableString sequence, List<String> color) {
    int hex = Color.parseColor(color.get(0));

    sequence.setSpan(new BackgroundColorSpan(hex), 0, sequence.length(), 0);
    return sequence;
}

From source file:Main.java

public static Bitmap createBitmap(Bitmap bitmap, final String s) {
    bitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.parseColor(s));
    return bitmap;
}

From source file:Main.java

private static int parserColor(String value) {
    String regularExpression = ",";
    if (value.contains(regularExpression)) {
        String[] temp = value.split(regularExpression);

        int color = Color.parseColor(temp[0]);
        int alpha = Integer.valueOf(temp[1]);
        int red = (color & 0xff0000) >> 16;
        int green = (color & 0x00ff00) >> 8;
        int blue = (color & 0x0000ff);

        return Color.argb(alpha, red, green, blue);
    }//from   w  w w . j  a  v a 2 s .co  m
    return Color.parseColor(value);
}

From source file:Main.java

public static int HextoColor(String color) {
    // #ff00CCFF/* w w  w  .j a v  a  2  s  .c o  m*/
    String reg = "#[a-f0-9A-F]{8}";
    if (!Pattern.matches(reg, color)) {
        color = "#00ffffff";
    }

    return Color.parseColor(color);
}