An open API service indexing awesome lists of open source software.

https://github.com/scionoftech/convertviewtoimage

Convert layout to bitmap image.
https://github.com/scionoftech/convertviewtoimage

Last synced: 3 months ago
JSON representation

Convert layout to bitmap image.

Awesome Lists containing this project

README

          

#ConvertViewtoImage

Convert layout to bitmap image.

```java

view.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null

view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());

view.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false); // clear drawing cache

```
## License

[MIT](LICENSE)