android how to draw a bitmap on canvas semi transparent

GideonKain picture GideonKain · Sep 16, 2011 · Viewed 18.6k times · Source

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

Answer

waychow picture waychow · Sep 16, 2011
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);