android how to draw a bitmap on canvas semi transparent-ThrowExceptions

Exception or error:

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

How to solve:
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);


Paint p = new Paint();

Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper);
canvas.drawBitmap(image, xPosition, yPosition, p); 

Leave a Reply

Your email address will not be published. Required fields are marked *