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

  • Home
  • SEARCH
  • 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 7308847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:37:38+00:00 2026-05-28T23:37:38+00:00

I have read all the pages I could find about support multiple screens in

  • 0

I have read all the pages I could find about support multiple screens in android, including

Supporting Multiple Screens

Providing Resources

Screen Sizes and Densities

And many others. But I still don’t understand what resources I should provide for it to correctly position drawables(sprites) on a Canvas.

It’s my first time making a game and I am currently a game Whack a Mole. I am confused about how to use the ldpi, mdpi, and hdpi, folders and how to properly position sprites to draw over a SurfaceView canvas.

I have a background image, resolution 480×800, so I added it to my hdpi folder. Then I have 120×150 sprites of moles, that I should position correctly on the holes for that background.

Currently I am using the following code to draw it:

canvas.drawBitmap(toDrawBitmap, draw_x, draw_y, null);

draw_x and draw_y are pixels that I found trying to place them correctly:

So far everything is fine, they are correctly placed in my hdpi, 480×800 screen. And android re scales them correctly on the different resolutions.

But when I try to use a different resolution screen, they are all drawn in wrong places, out of the holes, some of them are even out of the screen.

Please correct me if I am wrong but for what I’ve read these three resolutions are the most common in phones:

240×320 small – ldpi

320×480 normal – mdpi

480×800 normal – hdpi

My goal is to make the game work properly in those three kinds of screen. So my question is:

Can I calculate a draw_x and draw_y value, that will work on all of the devices? If not, how do i solve this problem?

  • 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-28T23:37:39+00:00Added an answer on May 28, 2026 at 11:37 pm

    Yes you can calculate it using device width and height.

    final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    
    final int width = display.getWidth();
    final int height = display.getHeight();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already read all the previous similar posts but I couldn't find a
I have read a lot about soft deletes and archive and saw all the
I have read all the docs I can get my hands on and google'd
Okay guys, I have read through all the other posts and question on jQuery
I just want what my title says.I have already read all the previous similar
I have read through the solutions to similar problems, but they all seem to
First of all let me tell you that i have read the following questions
To create a daemon I have read somewhere that in order to close all
I am currently building a site and all the books I have read on
I have massive directories, and I would like to read all the files as

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.