Android Snippet: Draw layout to a Bitmap

29 Dec
December 29, 2012

I needed this code for a project, where I needed to capture a certain list item I was rendering into a Bitmap and upload it using Facebook’s SDK.

This snippet basically “screen captures” and draws a certain view and saves it as a Bitmap and is the right way to do this.

Another solution to this is trying to draw everything on Canvas* “manually”, but taking the time to figure out all the bounds and text sizes, and getting the exact positions of things on a canvas sound like a real inconvenience. This makes it the wrong way to do this.

And you’re done!

Tags: , , , , ,
7 replies
  1. Patryk says:

    Cool thing, I made a small project from that some time ago

  2. nadavfima says:

    Using the same technique, right?

  3. Felipe Calderon barragan says:


    I love this library and I added one of my projects. the problem is that when viewing the interface under OS Ice Cream Sandwich looks like the picture shows. Can you tell me a way to correct it and make the correction. I am willing to work on it but can not find the way to make it compatible for minor API.

  4. expert zone says:

    I do not even understand how I stopped up right here, however I believed this post was once
    great. I dont know who you are but definitely you are going to a well-known blogger if you are not already

  5. says:

    I really love your site.. Pleasant colors & theme. Did you build this website yourself?

    Please reply back as I’m attempting to create my own personal blog and
    want to know where you got this from or exactly what the theme is called.
    Many thanks!


  6. Dewayne says:

    This article is very interesting but it took me a long time to find it in google.
    I found it on 17 spot, you should focus on quality backlinks
    building, it will help you to rank to google top 10.
    And i know how to help you, just type in google – k2 seo tips and tricks

  7. Roxanna says:

    Finally i quit my regular job, now i earn decent money
    on-line you should try too, just type in google – bluehand
    roulette system


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>