20

I have tried to modify a Paint variable, but have been unsuccessful - how can I make a bitmap appear "semi-transparent"?

GideonKain
  • 744
  • 1
  • 12
  • 27

2 Answers2

50
canvas.drawColor(Color.WHITE);   
BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.loading);    
Bitmap bm = bd.getBitmap();    
Paint paint = new Paint();    
paint.setAlpha(60);                             //you can set your transparent value here    
canvas.drawBitmap(bm, 0, 0, paint);
Adinia
  • 3,722
  • 5
  • 40
  • 58
waychow
  • 544
  • 5
  • 2
1
Paint p = new Paint();
p.setAlpha(70);

Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper);
canvas.drawBitmap(image, xPosition, yPosition, p); 
Sam
  • 40,644
  • 36
  • 176
  • 219
praveen s
  • 209
  • 4
  • 11