List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:Main.java
public static int getRandomColor() { List<Integer> colors = new ArrayList<>(); colors.add(Color.BLACK); colors.add(Color.RED);/*w ww . j av a2s . com*/ colors.add(Color.GREEN); colors.add(Color.BLUE); colors.add(Color.YELLOW); colors.add(Color.GRAY); colors.add(Color.MAGENTA); colors.add(Color.CYAN); colors.add(Color.LTGRAY); return colors.get(new Random().nextInt(colors.size())); }
From source file:Main.java
public static int getContrastColor(String colorString) { int color = Color.parseColor(colorString); double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000; if (y >= 128) { return Color.BLACK; } else {// w ww. jav a 2s . c o m return Color.WHITE; } }
From source file:Main.java
public static int parseBackgroundColor2(int color) { int counter = 0; counter += Color.red(color) >= 128 ? 1 : 0; counter += Color.green(color) >= 128 ? 1 : 0; counter += Color.blue(color) >= 128 ? 1 : 0; return counter >= 2 ? Color.BLACK : Color.WHITE; }
From source file:Main.java
public static int ContrastColor(int color) { int d = 0;/* w ww . j av a 2 s. c o m*/ // Counting the perceptive luminance - human eye favors green color... double a = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255; if (a < 0.5) return Color.BLACK; // bright colors - black font return Color.WHITE;// dark colors - white font }
From source file:Main.java
public static int getDominantColor(Bitmap bitmap) { try {//w ww . j av a 2s . co m Bitmap onePixelBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true); return onePixelBitmap.getPixel(0, 0); } catch (Exception ex) { return Color.BLACK; } }
From source file:Main.java
public static Paint getScoreColor() { Paint paint = new Paint(); paint.setColor(Color.WHITE);/* w w w . j a v a2 s .co m*/ paint.setTextSize(80); paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setShadowLayer(3, 5, 5, Color.BLACK); return paint; }
From source file:Main.java
public static int parseColor(String colorString) { try {//from ww w . j a v a 2s . c om return Color.parseColor(colorString); } catch (IllegalArgumentException e) { if (isShortColorCode(colorString)) { return parseShortColorCode(colorString); } else { return Color.BLACK; } } }
From source file:Main.java
public static int getHighlightColorFromBackground(final Activity activity) { int incolor = Color.BLACK; final Bitmap screenshot1px = getScaledScreenshot(activity, 1, 1, false); if (null != screenshot1px) { incolor = screenshot1px.getPixel(0, 0); }// w ww .j a v a2s. c o m return getHighlightColor(incolor); }
From source file:Main.java
public static void applyDialogStyle(ViewGroup viewGroup) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return;//w w w . java2 s . com } viewGroup.setBackgroundColor(Color.BLACK); // Theme.AppCompat.Light makes all text and background black final int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View childView = viewGroup.getChildAt(i); if (childView instanceof ListView) { childView.setBackgroundColor(Color.LTGRAY); } else if (childView instanceof ViewGroup) { applyDialogStyle((ViewGroup) childView); } else if (childView instanceof TextView) { ((TextView) childView).setTextColor(Color.WHITE); } } }
From source file:Main.java
public static Bitmap createPngScreenshot2(View view, int thumbnailWidth, int thumbnailHeight, int top) { if (view != null) { Bitmap mCapture;//from w w w. j av a 2 s . c o m try { mCapture = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_8888); } catch (OutOfMemoryError e) { return null; } Canvas c = new Canvas(mCapture); c.drawColor(Color.BLACK); // final int left = view.getScrollX(); // final int top = view.getScrollY(); c.translate(0, -top); //c.scale(0.65f, 0.65f, left, top); try { // draw webview may nullpoint view.draw(c); } catch (Exception e) { } return mCapture; } return null; }