以下是针对,?canvas.drawBitmap方法实施透明效果.
Paint paint = new Paint(); paint.setAlpha(0x40); //设置透明程度canvas.drawBitmap(this.bitmap, this.offsetX, this.offsetY,paint);
如果是针对图片的drawable,则可以
Drawable ibSelected; ...定义DrawableibSelected.setBounds(0, 0, itemImageWidth+2, itemImageHeight+2);((BitmapDrawable)ibSelected).getPaint().setAlpha(0x40);ibSelected.draw(canvas);
同理NinePatchDrawable也可以用同样处理. 其实也就是设置画笔(Paint)的透明度.