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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:15:11+00:00 2026-05-20T23:15:11+00:00

I am writing a View that should show a drawable that seems to never

  • 0

I am writing a View that should show a drawable that seems to “never end”.
It should be twice or third the displaysize and move slow through the display.

Therefore I studied some samplecode by Google and found the important Lines

public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {
    canvasWidth = width;
    canvasHeight = height;
    float sf = backgroundImage.getWidth() / canvasWidth;
    backgroundImage = Bitmap.createScaledBitmap(backgroundImage,
        (int) (canvasWidth * sf), canvasHeight, true);
    }

To rescale the image and than

        // decrement the far background
        backgroundXPos = backgroundXPos - DELTAMOVE;
        // calculate the wrap factor for matching image draw
        int newFarX = backgroundImage.getWidth() - (-backgroundXPos);
        // if we have scrolled all the way, reset to start
        if (newFarX <= 0) {
            backgroundXPos = 0;
            // only need one draw
            canvas.drawBitmap(backgroundImage, backgroundXPos, 0, null);

        } else {
            // need to draw original and wrap
            canvas.drawBitmap(backgroundImage, backgroundXPos, 0, null);
            canvas.drawBitmap(backgroundImage, newFarX, 0, null);
        }

To draw the moving image. The images is already moving, it’s fine.

But, and this is the point of my question, the image looks very ugly. Its original is 960*190 pixels by 240ppi. It should be drawn inside a view with 80dip of height and “fill_parent” width.

It should look same (and good) on all devices. I have tried a lot but I don’t know how to make the picture look nice.

Thanks for your help.
Best regards,
Till

  • 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-20T23:15:12+00:00Added an answer on May 20, 2026 at 11:15 pm

    Since you’re saying that it’s a never ending drawable, probably you’re writing a game of some sort. If your image is a pixel-art type, then you don’t want any scaling; pixel-art-type images cannot be scaled and keep its crisp look (you can try using nearest neighbor interpolation and scaling to an integer multiple of the original, which sometimes might work, but sometimes you will still need manual tweaks). This is the rare case where you actually would need to have different image resource for different screen resolutions.

    Otherwise you might want to use a vector image, but if — as you said — your original is a high resolution image, then vector image probably won’t help much here.

    btw, you probably want to show some screenshot. “Looks ugly” is just as helpful as saying my code does not work.

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

Sidebar

Related Questions

I'm writing a simple browser-based front end that should be able to launch a
I am writing an app that allows user to view the list of installed
Ok, I'm trying to end up with a view that returns some fields from
I am currently writing an app that should display a real time measurement curve
I'm writing a program that should run every 10 minutes in the background. The
I am writing a view controller for adding a new item to my app.
I'm writing a database view to sum up a bunch of records where the
I'm writing a WPF application and trying to bind an image to my view
I am writing an audio player for OSX. One view is a custom view
I am using Mvc3 and my view engine is razor and also writing jquery

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.