原理:建立一個新的Bitmap,而後再根據它來建立一個Canvas,最後調用View的draw方法將View畫到Canvas上,這樣獲得的Bitmap就是咱們想要的。java
代碼:canvas
public Bitmap createViewBitmap(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas); return bitmap; }