Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Drawable looks ugly due to scaling
    text
    copied!<p>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.</p> <p>Therefore I studied some samplecode by Google and found the important Lines</p> <pre><code>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); } </code></pre> <p>To rescale the image and than</p> <pre><code> // 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 &lt;= 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); } </code></pre> <p>To draw the moving image. The images is already moving, it's fine.</p> <p>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.</p> <p>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.</p> <p>Thanks for your help. Best regards, Till</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload