0
    imageView.setColorFilter(Color.argb(255, 255, 255, 255));

I would like to change the alpha value to 10 percent (25) like this.

    imageView.setColorFilter(Color.argb(25, 255, 255, 255));

But the color become black rather than transparent white. Any thoughts?

JayVDiyk
  • 4,277
  • 22
  • 70
  • 135

3 Answers3

1

you can use Color.parseColor and give transparency in hexa code

imageView.setColorFilter(Color.parseColor("#1AFFFFFF"));

here first 2 letters 1A is your transparency code.

for more transparency code check this

Community
  • 1
  • 1
Ravi
  • 34,851
  • 21
  • 122
  • 183
1

Set a mode. setColorFilter(Color.argb(25, 255, 255, 255),PorterDuff.Mode.MULTIPLY);

Josh.M
  • 103
  • 4
1

agree with @RRR you can use this too

define trans_black in color.xml with code #1A000000

ImageView logoImage = (ImageView) findViewById(R.id.logo);
logoImage.setColorFilter(getApplicationContext().getResources().getColor(R.color.trans_black));
Ram Mandal
  • 1,899
  • 1
  • 20
  • 35