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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:46:03+00:00 2026-06-10T03:46:03+00:00

I have read the screen support API guide (http://developer.android.com/guide/practices/screens_support.html) and much more resources, but

  • 0

I have read the “screen support API guide “(http://developer.android.com/guide/practices/screens_support.html) and much more resources, but I cannot understand how the dpi works.

I’m developing a game, and I’m not using any layouts (I’m going to draw all myself with functions like canvas.drawbitmap). But when I use the Canvas.Drawbitmap function I need to specify the pixels of the screen where I want to draw the image.

So I’m working now with a fixed resolution (1280×800) and I’m using the drawable-nodpi folder and adjusting the canvas later if the screen of the phone is wider or narrow. The problem with that is that the images look horrible when the resolution is not the native one (1280×800).

What can I do to solve this problem? I’ve read and read during 3 days, but all explanations and examples are related to Layouts, Nine Patches and so.

  • 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-10T03:46:04+00:00Added an answer on June 10, 2026 at 3:46 am

    Get the density of the device being used and multiply that density by some base size that you pick (how big or small do you actually want it to be drawn?)

    Example:

    float objectToDrawHeight = 50; //Specified in plain pixels
    float objectToDrawWidth = 50; //Specified in plain pixels
    
    float density = getResources().getDisplayMetrics().density;
    objectToDrawHeight *= density;
    objectToDrawWidth *= density;
    
    //Draw your object using the new (scaled) height and width
    //If you are worried about how the object will look on different aspect ratio devices
    //  you can get the screen dimensions and use that ratio as a multiplier
    //  just as you did with density
    
    Display display = ((Activity)context).getWindowManager().getDefaultDisplay();
    float screenDimensionX = display.getWidth();
    float screenDimensionY = display.getHeight();
    

    Using density and possibly screen dimensions should allow you to draw anything and keep it scaled correctly. When using canvas, assume everything is in pixels, and that you must do the dpi conversion.

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

Sidebar

Related Questions

I have read http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/reference/android/util/DisplayMetrics.html and I somehow left with a gap here.
I have read pretty much the entire documentation even beyond on the AWS AS
I have read the following which is from Best Practices for Encoding Video with
I have read that it is best to aim keep functions to no more
I understand that Android's developer site provides information on this topic. I have already
I have read several times android documentation about the GetView DataAdapter class. From what
If an application have to support starting from android 1.6 device and onwards. The
I have read all the pages I could find about support multiple screens in
I am developing a program on android version2.2. I have read many documentation on
so far i have read how to load "normal" html webpages in a webview

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.