根據view生成Bitmap

2021-06-06 12:44:34 字數 398 閱讀 2021

private bitmap getviewbitmap(view v)

v.builddrawingcache();

bitmap cachebitmap = v.getdrawingcache();

if (cachebitmap == null)

bitmap bitmap = bitmap.createbitmap(cachebitmap);

// restore the view

v.destroydrawingcache();

v.setwillnotcachedrawing(willnotcache);

v.setdrawingcachebackgroundcolor(color);

return bitmap;

}

將view物件轉化為Bitmap

如題 private bitmap getviewbitmap view view view.builddrawingcache bitmap cachebitmap view.getdrawingcache if cachebitmap null bitmap bitmap bitmap.crea...

自定義view轉Bitmap

將自定義view填充資料後,轉成bitmap,填充到imageview中 1.自定義布局 裡面是recycleview用於填充資料,constraintlayout是為了設定寬高生效,多加了層布局 test.xml 2.bitmaputils工具類 view.measurespec.exactly ...

生成帶數字的Bitmap

public class markediconproducer paint paint new paint paint.anti alias flag paint numpaint new paint paint.anti alias flag numpaint.setcolor color.whi...