美文网首页
把一个view转换为Bitmap的方法(app界面截图)

把一个view转换为Bitmap的方法(app界面截图)

作者: 茶And狗狗 | 来源:发表于2017-03-21 18:09 被阅读0次

应用的地方,app中需要保存某个页面的截图,可以用到;

public static Bitmap convertViewToBitmap(View view){
      view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
        view.buildDrawingCache();
        Bitmap bitmap = view.getDrawingCache();
     return bitmap;
}

引用:http://www.cnblogs.com/devinzhang/archive/2012/06/05/2536848.html

相关文章

网友评论

      本文标题:把一个view转换为Bitmap的方法(app界面截图)

      本文链接:https://www.haomeiwen.com/subject/ddbgnttx.html