android-particles
android-particles copied to clipboard
Setting background drawable
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!
I am having the same issue
También tengo el mismo problema.
Same issue here, the background is black
#helpinghands
@ibrahimsn98
init { obtainStyledAttributes(attrs, defStyleAttr) if (holder != null) holder.addCallback(this) hasSurface = false setZOrderOnTop(true) holder.setFormat(PixelFormat.TRANSLUCENT) }
是的 我也有相同的问题 即使将background属性去掉了之后依旧如此 but whatever thanks guys
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 theonSurfaceTextureAvailable
andonSurfaceTextureDestroyed
- Create a
Surface
instance so you can get the canvas and draw. Should be initialized inonSurfaceTextureAvailable
and released inonSurfaceTextureDestroyed
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);