Coder Social home page Coder Social logo

Comments (4)

plattysoft avatar plattysoft commented on September 22, 2024 1

This is duplication of #21, but at least your title and code explanation is much more detailed and clear. Actually it is a great report.

I'm doing a copy and paste from the other ticket:

It is due to how Android works.

For the particle system to work fine, the views must be measured when it is created. Inside onCreate the Views are not yet measured, just created. You need to set a ViewTreeObserver to know when the layout has been measured.

This is a standard question on Android, check out this link on Stack Overflow, it is exactly the same problem: http://stackoverflow.com/questions/3779173/determining-the-size-of-an-android-view-at-runtime

That being said, I'd leave this one open because I want to improve the code so this special case can be done automatically. I'm afraid that, in the meantime, you need to go with the ViewTreeObserver

from leonids.

leglopy avatar leglopy commented on September 22, 2024

Thanks for your help, that works with the ViewTreeObserver ;)

from leonids.

rishirajput avatar rishirajput commented on September 22, 2024

Hey, I was also having a problem with all particles showing up on top left corner regardless of anchor view positions on launch. The problem was the anchor view was not ready while starting the animation. So you can put the animation code inside View.post(Runnable) or View.postDelayed(Runnable) method. This fixed the issue of particales whithout onclick for me.

findViewById(R.id.center_anchor).post(new Runnable() {
@OverRide
public void run() {
new ParticleSystem(ModeSelectionActivity.this, 100, R.drawable.ic_gem_green, 30000)
.setSpeedRange(0.2f, 0.5f)
.oneShot(findViewById(R.id.center_anchor), 100);
}
});

If this helps out, Good Luck :)

from leonids.

plattysoft avatar plattysoft commented on September 22, 2024

Posting a runnable, even with a delay does not guarantee a fix. You need to start the emitter after the views have been measured. Posting a runnable is a gamble that works 99.9% of the time, but if the phone is slow for whatever reason, it will not work.
The only way to make sure it works is the tree observer.

from leonids.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.