List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:Main.java
/** * Generate a color filter with a given color. * @param color The color the filter represents. * @return A color filter that can be used to set background colors of image views. *///w ww. j a va 2s .c om public static ColorFilter getColorFilter(String color) { int iColor = Color.parseColor(color); return getColorFilter(iColor); }
From source file:Main.java
public static int getColor(String color) { int[] icolors = getArgbValue(color); int icolor = Color.rgb(0, 0, 0); if (icolors.length == 3) { icolor = Color.rgb(icolors[0], icolors[1], icolors[2]); } else if (icolors.length == 4) { icolor = Color.argb(icolors[0], icolors[1], icolors[2], icolors[3]); } else {/*from w ww . j a v a 2 s . co m*/ icolor = Color.parseColor(color); } return icolor; }
From source file:Main.java
public static int randomRGB() { String r, g, b;/*from w ww .j a v a2 s.c om*/ Random random = new Random(); r = Integer.toHexString(random.nextInt(256)).toUpperCase(); g = Integer.toHexString(random.nextInt(256)).toUpperCase(); b = Integer.toHexString(random.nextInt(256)).toUpperCase(); r = r.length() == 1 ? "0" + r : r; g = g.length() == 1 ? "0" + g : g; b = b.length() == 1 ? "0" + b : b; return Color.parseColor("#" + (r + g + b)); }
From source file:Main.java
public static Bitmap highlightSelectedFaceThumbnail(Bitmap originalBitmap) { Bitmap bitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true);// w w w .ja va2s . co m paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.parseColor("#3399FF")); int stokeWidth = Math.max(originalBitmap.getWidth(), originalBitmap.getHeight()) / 10; if (stokeWidth == 0) { stokeWidth = 1; } bitmap.getWidth(); paint.setStrokeWidth(stokeWidth); canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), paint); return bitmap; }
From source file:Main.java
public static int getColorFromHex(String color) { if (color.contains("0x")) color = color.replace("0x", ""); // if (color.contains("#")) // color = color.replace("#", ""); // return Integer.parseInt(color, 16) + 0xFF000000; if (!color.contains("#")) { StringBuffer colorBuffer = new StringBuffer("#"); colorBuffer.append(color);/* w w w. ja v a 2 s. co m*/ return Color.parseColor(colorBuffer.toString()); } // return Color.parseColor(color); // StringBuffer colorBuffer = new StringBuffer("0xff"); // colorBuffer.append(color); // int value = Integer.parseInt(colorBuffer.toString(), 16); // int red = ((value >> 24) & 0xFF) / 255; // int green = ((value >> 16) & 0xFF) / 255; // int blue = ((value >> 8) & 0xFF) / 255; // int alpha = ((value >> 0) & 0xFF) / 255; // Color.parseColor(colorString); // return Color.argb(alpha, red, green, blue); }
From source file:Main.java
public static Bitmap createIdenticon(byte[] hash) { int background = Color.parseColor("#00000000"); return createIdenticon(hash, background); }
From source file:Main.java
public static void makeAboutSpannable(SpannableStringBuilder span, String str_link, String replace, final Runnable on_click) { Pattern pattern = Pattern.compile(str_link); Matcher matcher = pattern.matcher(span); ForegroundColorSpan color_theme = new ForegroundColorSpan(Color.parseColor("#53b7bb")); if (matcher.find()) { span.setSpan(new ClickableSpan() { @Override/*from w ww . ja v a2 s . c om*/ public void onClick(View widget) { if (on_click != null) on_click.run(); } }, matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(color_theme, matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (replace != null) span.replace(matcher.start(), matcher.end(), replace); } }
From source file:Main.java
/** * To determine color of total mem in "new" dialog * /*from www .j a v a 2s. c o m*/ * @param c * Size of cache * @param d * Size of data * @param s * Size of system * @return color of mem */ public static int getMemColor(int c, int d, int s) { int SD_FREE_SIZE = sdFreeSize(); int SD_WARN_SIZE = (int) (SD_FREE_SIZE * 0.9); int TOTAL_SIZE = getTotalSize(c, d, s); if (TOTAL_SIZE > SD_FREE_SIZE) return Color.RED; else if (TOTAL_SIZE > SD_WARN_SIZE) return Color.parseColor("#FFA500"); else return Color.parseColor("#4B8A08"); }
From source file:Main.java
private static int parseColor(String colorName) { return Color.parseColor(colorName.toLowerCase()); }
From source file:Main.java
public static int GetRandomColor() { Random random = new Random(); int p = random.nextInt(Colors.length); while (Colors[p].equals(lastColor0) || Colors[p].equals(lastColor1) || Colors[p].equals(lastColor2)) { p = random.nextInt(Colors.length); }/*w w w. ja v a2 s .c o m*/ lastColor0 = lastColor1; lastColor1 = lastColor2; lastColor2 = Colors[p]; return Color.parseColor(Colors[p]); }