I am trying to make an android application in which i would like to have bubbles which float on the screen when some action takes place. Could some one please help me here. I am breaking my head for the past four days but i could not make it up. So please help me here. Thanks in advance.
Share
Instead of using ImageViews, for your use case, it would be better to use a Canvas to handle the drawing yourself.
Draw a canvas fullscreen with a transparent background. Create an array of bitmaps(one for each image you want to draw, remember to use a circle mask to make them bubble shaped, watch out for memory issues) and draw them to screen at different positions.
Use a custom RNG algorithm to generate appropriate positions for your bitmaps, and then draw them on the canvas. Use a Thread to handle the animations.
Here‘s the code for generating a circular cropped bitmap:
Of course, you will have to modify this code to draw the bitmap to the canvas instead of setting it in the ImageView. It would be more efficient, to crop the Bitmap once, then place the cropped image into the array of Bitmaps.