Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:18:12+00:00 2026-05-26T04:18:12+00:00

I am looking to take a view hierarchy and turn it into a Bitmap.

  • 0

I am looking to take a view hierarchy and turn it into a Bitmap. Using the view.getDrawingCache() does exactly what I want it to do but will not work if I try that before the view is drawn. Is there another function that will do the same thing but before it is actually drawn? I would like to create the view and turn it into a bitmap to display and discard the actual view. If there is a way to force the view to be drawn that might work as well. Any ideas?

I found this in a previous post:

    public static Bitmap loadBitmapFromView(View v) {
         Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
         Canvas c = new Canvas(b);
         v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
         v.draw(c);
         return b;
    }

This looks promising but when I use it all I get is a semi transparent black box.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:18:13+00:00Added an answer on May 26, 2026 at 4:18 am

    Alright I figured it out. You can use this code, slightly modified from this post.

        public static Bitmap loadBitmapFromView(View v) {
              Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
              Canvas c = new Canvas(b);
              v.measure(v.getLayoutParams().width, v.getLayoutParams().height); //Change from original post
              v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
              v.draw(c);
              return b;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a simple program that will take tallPDF xml and convert it into
Im looking for a script that will take OData feed and download some .wmv
I am looking for a tool which will take an XML instance document and
I am looking into converting my OpenGL rendering code to take advantage of a
I'm looking for an easy way to call a bean's method that will take
I'm looking for a way to parse a text to turn into links the
Take ILSPy . When I view my assembly am I looking at my original
I don't know if the term I'm using is right, but what I'm looking
I'm looking into integrating Ember with an existing Rails application, to take advantage of
I'm looking to take the results of a report run (a PDF file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.