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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:47+00:00 2026-05-29T08:41:47+00:00

I have a View-derived class where I draw a 790×500 (yes, this is odd

  • 0

I have a View-derived class where I draw a 790×500 (yes, this is odd but it has to stay this way) bitmap directly on the canvas in onDraw. This looks ok on my Nexus S, but when I run my app on a device with a smaller screen (e.g. Wildfire) I only see the upper left part of the bitmap. What am I missing here?

This is a game-like app where I draw a number of bitmaps on certain coordinates. I really don’t want to have different pixel setups for LDPI, MDPI and HDPI (I have a good reason for this).

Q: How can I properly scale my bitmaps for any screen resolution? (Centering the game screen for large screens may be an option, but is not a must.) E.g. when I draw a 800×600 image on a 320×240 screen, the image is automatically stretched and when I output a pixel at 100×100, it becomes 40×40.

  • 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-29T08:41:48+00:00Added an answer on May 29, 2026 at 8:41 am

    There are many forms of the drawbitmap() method. Choose the one that allows you to specify the source and destination rectangle. The source rectangle will be the size of your bitmap and the destination rectangle will be scaled to fit on the device display. Android will scale your bitmap when it draws it.

    Rect rs = new Rect();
    Rect rd = new Rect();
    rs.left = rs.top = 0;
    rs.right = 789;
    rs.bottom = 499;
    
    <calculate destination rectangle from device size>
    
    canvas.drawBitmap(myBitmap, rs, rd, null);
    

    You can also scale and translate (shift) the entire canvas

    canvas.scale(float scaleX, float scaleY);
    canvas.translate(float dx, float dy);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a view derived class named MyView. In the same Xcode project
i have view like 'home/details/5', it can be access by anonymous user. but there
I have a view that has a list of jobs in it, with data
I have a view user control that can post form. This control can be
I have a View class (OrderView.aspx) which shows the details of an order (Account
I have a ListView-derived class which creates a bunch of user controls that are
I have a very simple app that processes touches on a UIImageView derived view.
I have a cusom view derived from TableLayout, and I need to declare String
I have a button that's created via a NIB file. I've derived a class
I have an application where I have one custom view which is derived 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.