How to draw a scrolling background for an Android game

I want to draw an image that in some levels may be larger than the screen as a background for an android game. I want the user to be able to scroll the image with his finger on the touchscreen.

This is how I draw the background:

Bitmap scratch =  BitmapFactory.decodeResource(getResources(),R.drawable.background);
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(scratch, 0, 0, null);

      

+2


source to share


1 answer


You can use ImageView

and put it in ScrollView

- I suspect this is not what you want. If not, you'll have to collapse yourself - take a look at GestureDetector for help with navigation gestures.



0


source







All Articles