Posts /

Making bitmaps from layouts in background

17 Jul 2016

Synthesize lets you make bitmaps without inflating them and in background.

Drawing the exact image shown in the layout can be a difficult task on Canvas. Defining the margins, colors, typeface, text wrapping, etc. is a huge task to accomplish manually. To draw on a canvas you must also define the styles. Generating bitmap from the layouts gives you freedom from the headaches drawing on the canvas.


Here comes Synthesize to the rescue. All you have to do is initialize the layout XML as you would do in any activity or fragment using Synthesize, the only difference is that you can now do it in background.


    //Project Level gradle
    allprojects {
        repositories {
            maven { url "" }

    //Module Level gradle
        compile "com.prashantsolanki:Synthesize:0.1.5"


    Synthesize s= new Synthesize(this,R.layout.resource_id);
    s.generateBitmap(new OnBitmapGenerationListener(){
            void onSuccess(Bitmap bitmap){

            void onError(Exception e){


Required methods
Optional methods