Android(安卓)Bitmap 透明度(Picture 透明度)
16lz
2022-07-22
Android可透过 Paint 物件,来设定Bitmap透明度.
转自:http://disanji.net/2010/12/11/android-bitmap-picture/
Java 程式范例 :
public class helloWorld extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( new drawCanvas(this) ); } class drawCanvas extends View { public drawCanvas(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // 取得Resource 图片的Bitmap Bitmap vBitmap = BitmapFactory.decodeResource( this.getResources() , R.drawable.icon ); // 建立Paint 物件 Paint vPaint = new Paint(); vPaint .setStyle( Paint.Style.STROKE ); //空心 vPaint .setAlpha( 75 ); // Bitmap透明度(0 ~ 100) canvas.drawBitmap ( vBitmap , 50, 100, null ); //无透明 canvas.drawBitmap ( vBitmap , 50, 200, vPaint ); //有透明 } }}
转自:http://disanji.net/2010/12/11/android-bitmap-picture/
更多相关文章
- android Dialog大小修改
- Andorid Dialog 示例【慢慢更新】
- Hello Android(安卓)- android窗体透明的,黑暗度等的设置技巧
- ListView美化
- Android(安卓)全面屏的和有导航栏的判断
- Android(安卓)透明度数值
- android设置view透明度的效果
- Android(安卓)颜色设置:透明度换算
- Android颜色全解析