I’m using a SurfaceView in Android. The application is always in landscape mode.
In my res/drawable folder I have a large background that is also in landscape mode but larger than most display sizes.

Now I would like to set it as the background of the SurfaceView so that it perfectly fits into the display. So the image’s height should be equal to the display’s height.

How do I do that? Do I have to use alternative resources for ldpi, mdpi, hdpi and xhdpi? But even then I don’t know the exact height of the display.
I’m currently using:
canvas.drawBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.background), 0, 0, null);
I tried to resize the bitmap using a matrix. But then the quality of the image becomes really poor, doesn’t it?
(Of course, the solution should be performant, too.)
1 Answer