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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:26:45+00:00 2026-06-14T21:26:45+00:00

I am manually creating a SurfaceView in code and setting it as content view

  • 0

I am manually creating a SurfaceView in code and setting it as content view on my activity like this:

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
int height = displaymetrics.heightPixels;
mainSurface = new MainSurface(getBaseContext());
mainSurface.getHolder().setFixedSize(width, height);
setContentView(mainSurface);

I then simply draw images like this on the canvas:

canvas = surfaceHolder.lockCanvas(null);
int id = context.getResources().getIdentifier("imageName", "drawable", context.getPackageName());
Bitmap image = BitmapFactory.decodeResource(context.getResources(), id);
canvas.drawBitmap(image, pos[0], pos[1], null);
surfaceHolder.unlockCanvasAndPost(canvas);

But things are strange… Some images/bitmaps are stretched and the positions work different from image to image so if I give two images the same position they are not placed the same place? It is like there are some layout management going on that I don’t know off, but how can that be? Should they not be absolute positions always when drawing on a SurfaceView?

I am totally puzzled!

EDIT
Ok it was because I only have images in the “drawable” folder, if I copy them to the “drawable-hdpi” they are not stretched! So to turn my question in another direction, can I make Android stop doing that? Can I make Android just use my images as-is even though if they only exist in the “drawable” folder and at the same time use those images (like the icon and such) that are in the different dpi folders?

  • 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-14T21:26:46+00:00Added an answer on June 14, 2026 at 9:26 pm

    It was because I only have images in the “drawable” folder, if I copy them to the “drawable-hdpi” they are not stretched!

    EDIT: In fact if you want to use the same images for all screens and not have them resized by Android, you can place them in a “drawable-nodpi” folder

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

Sidebar

Related Questions

Is there a way to do this in MOSS 2007? Instead of manually creating
I have been seeing this issue and resolving it by manually creating UINavigationController in
I'm manually creating a WCF service that will act as a DAL and have
Is there a difference in manually creating your (let's say db connection string) in
Manually built: [btnRun addTarget:self action:@selector(RunApp:) forControlEvents:UIControlEventTouchUpOutside]; Programmatically built: something of the following like ??
I can create database manually by going to cpanel. But I'd like to create
I am manually creating a multi-part MIME-formatted file and submitting it to an SMTP
In my Spring MVC based web-app, I'm manually creating an Errors/BindingResult object after manually
Im manually Creating the table using the built in razor GETHtml Function. @table.GetHtml( columns:
I have a question about manually creating a .Net webservice proxy class. The WSDL

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.