plattysoft / Leonids

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/
Apache License 2.0
2.28k stars 398 forks source link

How to show oneShot effect in DialogFragment's View? #80

Closed huuchi207 closed 7 years ago

huuchi207 commented 7 years ago

i use this code in DialogFragment:

ParticleSystem ps = new ParticleSystem(getActivity(), 70, R.drawable.star_pink, 800);
                                ps.setScaleRange(0.7f, 1.3f);
                                ps.setSpeedRange(0.1f, 0.25f);
                                ps.setRotationSpeedRange(90, 180);
                                ps.setFadeOut(200, new AccelerateInterpolator());
                                ps.oneShot(imageView, 70);

but the effect shows in Activity(behind Dialog) :(

plattysoft commented 7 years ago

By default, the ParticleSystem creates a full screen transparent view that is attached to the content view of the Activity as a first child - that is, on the very background -

To change that behaviour, you can provide another View as the parent, so the particle system can have views behind it. have you tried that?

huuchi207 commented 7 years ago

"you can provide another View as the parent". How can I try that? Can u give me an example code? In my code, imageView = (ImageView) rootView.findViewById(R.id.imageView). It's Dialog Fragment's View.

huuchi207 commented 7 years ago

I can't find out the constructor as you mention in documentation 's lib: " And another constructor that receives a parent viewgroup and drawable for use in places where it is not practical to pass a reference to an Activity

ParticleSystem(ViewGroup parentView, int maxParticles, Drawable drawable, long timeToLive)"

plattysoft commented 7 years ago

yes, that is the constructor you want to use. Yes, it is a ViewGroup, not a View, sorry I was talking from memory.

huuchi207 commented 7 years ago

untitled here is particle system 's contructors list. None of them has ViewGroup argument :(

plattysoft commented 7 years ago

Are you sure you are using the latest published version? It is one of the release notes https://github.com/plattysoft/Leonids/releases/tag/1.3.2

plattysoft commented 7 years ago

and you can see it in the code of that particular tag: https://github.com/plattysoft/Leonids/blob/1.3.2/LeonidsLib/src/main/java/com/plattysoft/leonids/ParticleSystem.java#L88

huuchi207 commented 7 years ago

ok let me try your suggest. Please change your construction 's setup section. It 's still guiding version 1.3.1 :D

huuchi207 commented 7 years ago

i solved my problem by using version 1.3.2. Thank you for your lib and your solution!