How to make bitmap transparent?

前端 未结 6 811
夕颜
夕颜 2021-01-14 11:40
/**
 * @param bitmap
 *            The source bitmap.
 * @param opacity
 *            a value between 0 (completely transparent) and 255 (completely
 *            op         


        
6条回答
  •  孤独总比滥情好
    2021-01-14 12:21

    Try this. Also note that setAlpha is in 0-255 range

    //bmp is your Bitmap object
    
    BitmapDrawable bd = new BitmapDrawable(bmp);
    bd.setAlpha(50);
    
    ImageView v = (ImageView) findViewById(R.id.image);
    v.setImageDrawable(bd);
    

提交回复
热议问题