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 7709595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:54:06+00:00 2026-06-01T00:54:06+00:00

I have a class that derives from ImageView . In its onDraw method override

  • 0

I have a class that derives from ImageView. In its onDraw method override I need to copy the view’s contents into a bitmap. The copy must contain the whole contents not just the visible portion.

To accomplish this I create a bitmap and invoke super.onDraw passing this bitmap’s canvas as the parameter. I then draw the resulting bitmap to the canvas that onDraw was passed. The code is below.

My question is how big my bitmap should be? Currently I use getWidth() and getHeight() as the bitmap’s dimensions. But this does not work because it returns the view size, not the contents size. I am looking for a way to get the size of the contents after the drawable has been resized according to the view’s scaleType.

The size of the drawable does not work because the drawable can be different from the contents dimensions.

    @Override
    public void onDraw(Canvas canvas)
    {
        if (_bitmap == null)
        {
            final int w = getWidth();
            final int h = getHeight();
_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); _canvas = new Canvas(_bitmap);
super.onDraw(_canvas); } canvas.drawBitmap(_bitmap, 0, 0, null); }

  • 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-06-01T00:54:08+00:00Added an answer on June 1, 2026 at 12:54 am

    Have you looked into

    getDrawingCache(boolean autoScale)

    Returns the bitmap in which this view drawing is cached.

    Set autoScale to true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a class 'MyTextBox' that derives from the default TextBox in Silverlight. This
Say I have a class named Base and a class that derives from it
I have a class that derives from ActiveRecord::Base. This class has a subclass that
I have a class called UserProfile, that derives from an object called User. How
I have a class with a dictionary object. Any class that derives from that
I have a class that derives from enable_shared_from_this ... (Recently been added to std
I have created a class that derives from TThread, because I wish to do
I have a class that derives from XNA's GraphicsDevice, and i want to use
I have a class that inherits from Dictionary<string, string> . Within an instance method,
I have my own TextBox2 class that derives from TextBox. I want to add

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.