android how to draw a bitmap on canvas semi transparent

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

Answers


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);

Paint p = new Paint();
p.setAlpha(70);

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

Need Your Help

Select Columns of a View

sql tsql view sql-view

I'm attempting to select the column names of a view in a similar way as selecting from information_schema.columns.

Why do immutable objects enable functional programming?

scala functional-programming

I'm trying to learn scala and I'm unable to grasp this concept. Why does making an object immutable help prevent side-effects in functions. Can anyone explain like I'm five?