1

I have these particles and I would like it to scroll down infinitely. What I mean is when whatever is drawn out of the screen when the particles scroll down, it goes back up and scrolls down from there again. enter image description here

Is this possible in android java? Someone please help.

perror
  • 7,071
  • 16
  • 58
  • 85
Troll PC
  • 85
  • 1
  • 1
  • 7

1 Answers1

0

Here is a simplified explanation of how you can do it.

//Load the image containing the background image
Bitmap imgSrc = BitmapFactory.decodeResource(this, R.drawable.background_image); 

//Crop it
Bitmap croppedImg = BitmapBitmap.createBitmap(imgSrc, 0,  y, imgSrc.getWidth(), cropHeight);

This code portion will crop your image into a smaller part and store the cropped image in the variable croppedImage. To better understand how the cropping occurs, check here. The variables y and cropHeight are, respectively, the ordinate of the point from which you want to start the cropping and the height of the cropped image that is being created.

To implement this the way you want, you have to create a "time loop" (this might help you creating one), that is, a structure that permits you to execute a block of code every X seconds, milliseconds, etc. On every loop, you will increment the variable y and draw the background. Be careful thought, for y must not go out of the background image's bound. Also make sure that the background image isn't too big, otherwise you will have memory problems (that you can solve by scaling the image when loading it).

Talendar
  • 1,841
  • 14
  • 23
  • I believe I have. I tried to make the explanation as succinct as possible (since my point here is to make you understand the process, not to make it for you), which may have created some confusion in my writing. However, this doesn't give you the right to be rude. I was only trying to help and used my time for that. (this is an answer for a deleted comment from "Troll PC"). – Talendar Aug 14 '18 at 01:12