android-particles icon indicating copy to clipboard operation
android-particles copied to clipboard

Setting background drawable

Open lukaIvanic opened this issue 4 years ago • 7 comments

First of all I would like to thank you for this amazing library, it's SO easy to use and the results are marvellous. It's also very easily customizable. Now for this issue, when I try to set a background drawable the particles don't appear. I tried setting the background colour to transparent and have a drawable somewhere behind, but instead of transparent, it's black. Do you have any idea how to solve this? It would be greatly appreciated!

lukaIvanic avatar May 31 '20 20:05 lukaIvanic

I am having the same issue

vevek avatar Jul 14 '20 10:07 vevek

También tengo el mismo problema.

LuiguiBalarezo avatar Nov 02 '20 20:11 LuiguiBalarezo

Same issue here, the background is black

hussein-yassine avatar Jan 14 '21 18:01 hussein-yassine

#helpinghands

@ibrahimsn98

init { obtainStyledAttributes(attrs, defStyleAttr) if (holder != null) holder.addCallback(this) hasSurface = false setZOrderOnTop(true) holder.setFormat(PixelFormat.TRANSLUCENT) }

mihirmodiofficial avatar Feb 03 '21 14:02 mihirmodiofficial

是的 我也有相同的问题 即使将background属性去掉了之后依旧如此 but whatever thanks guys

AudareLesdent avatar Jun 08 '22 03:06 AudareLesdent

This works if you do not have something on top of the SurfaceView, otherwise the SurfaceView will show on top of everything due to setZOrderOnTop set to true. An example would be the ParticleView library and a button in a middle (the button won't show).

An alternative would be to change the SurfaceView implementation to TextureView:

  • Change the listener to TextureView.SurfaceTextureListener and implement the methods accordingly (mainly the onSurfaceTextureAvailable and onSurfaceTextureDestroyed
  • Create a Surface instance so you can get the canvas and draw. Should be initialized in onSurfaceTextureAvailable and released in onSurfaceTextureDestroyed

zahichemaly avatar Oct 03 '22 13:10 zahichemaly

This is how I achieved transparent background. JAVA Solution, hope this helps someone.

ParticleView particleView = findViewById(R.id.particles_view);
particleView.setZOrderOnTop(true);
SurfaceHolder sfhTrackHolder = particleView.getHolder();
sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

akanshSirohi avatar Nov 25 '22 05:11 akanshSirohi