12

how to get parseColor color value to transparent.

mPaint.setColor(Color.parseColor("#FFFF00"));

thanks for help

Mattia Maestrini
  • 31,494
  • 15
  • 84
  • 93
Fou
  • 856
  • 2
  • 8
  • 19
  • Check out this answer: http://stackoverflow.com/questions/15852122/hex-transparency-in-colors – Jaz May 11 '15 at 14:02

4 Answers4

30

Suppose your preferred color is red #FF0000

Adding 00 in the beginning will make it 100% transparent and adding FF will make it 100% solid.

So, 100% transparent color is: #00ff0000 and 100% solid color is: #ffff0000

And any value in between 00 to ff can be used to adjust the transparency.

iphondroid
  • 498
  • 7
  • 19
Mohammad Arman
  • 6,898
  • 2
  • 35
  • 50
7

just used android color string

mPaint.setColor(getResources().getColor(android.R.color.transparent));
Angad Tiwari
  • 1,693
  • 1
  • 11
  • 22
1

You can use Color.TRANSPARENT if you do not want to change the transparency level.

import android.graphics.Color;

// use Color.TRANSPARENT
mPaint.setColor(Color.TRANSPARENT);

https://developer.android.com/reference/android/graphics/Color#TRANSPARENT

CrackerKSR
  • 710
  • 7
  • 19
0

You can use Color.argb(int alpha, int red, int green, int blue)

Alpha corresponds to transparency. 0 for fully transparent. 255 for opaque.

http://developer.android.com/reference/android/graphics/Color.html#argb(int,%20int,%20int,%20int)

Return a color-int from alpha, red, green, blue components. These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.

Knossos
  • 15,394
  • 10
  • 53
  • 89