Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting background drawable #5

Open
lukaIvanic opened this issue May 31, 2020 · 7 comments
Open

Setting background drawable #5

lukaIvanic opened this issue May 31, 2020 · 7 comments

Comments

@lukaIvanic
Copy link

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!

@vevek
Copy link

vevek commented Jul 14, 2020

I am having the same issue

@LuiguiBalarezo
Copy link

También tengo el mismo problema.

@hussein-yassine
Copy link

Same issue here, the background is black

@mihirmodiofficial
Copy link

mihirmodiofficial commented Feb 3, 2021

#helpinghands

@ibrahimsn98

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

@AudareLesdent
Copy link

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

@zahichemaly
Copy link

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

@akanshSirohi
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants