當前位置:首頁 » 安卓系統 » androidondraw

androidondraw

發布時間: 2025-05-25 12:36:49

『壹』 android是否可以以畫圖的形式將圖片畫在某位置

可以。

1、在View的onDraw中獲取canvas

java">@Override
protectedvoidonDraw(Canvascanvas){//onDraw中獲取參數中的canvas
//TODOAuto-generatedmethodstub
super.onDraw(canvas);
}

2、獲取圖片,轉化為Bitmap對象

//從資源文件中生成點陣圖bitmap
Bitmapbitmap=BitmapFactory.decodeResource(getResources(),R.drawable.icon);

3、通過canvas的drawbitmap方法,把圖片畫到任意位置。

//Bitmap:圖片對象,left:偏移左邊的位置,top:偏移頂部的位置
//rawBitmap(Bitmapbitmap,floatleft,floattop,Paintpaint)
canvas.drawBitmap(bitmap,10,60,paint);//在10,60處開始繪制圖片
熱點內容
環宇壓縮機 發布:2025-05-25 16:15:52 瀏覽:975
手機上怎麼改寬頻密碼 發布:2025-05-25 16:13:33 瀏覽:714
為什麼我的安卓自動升級鴻蒙了 發布:2025-05-25 16:05:43 瀏覽:332
互動游戲源碼 發布:2025-05-25 15:59:56 瀏覽:975
a了演算法題 發布:2025-05-25 15:58:19 瀏覽:71
androidota 發布:2025-05-25 15:33:14 瀏覽:607
什麼是分序加密 發布:2025-05-25 15:28:55 瀏覽:154
java二叉堆 發布:2025-05-25 15:24:59 瀏覽:762
主機管理系統源碼 發布:2025-05-25 15:12:39 瀏覽:513
資料庫網頁版 發布:2025-05-25 15:07:50 瀏覽:876