我需要制作粒子动画,但粒子总是从像素 0,0 开始

I need to make a particle animation but the particles always start from pixel 0,0

这是我需要制作的动画: https://www.dropbox.com/s/xvyj550i43gg6wz/2015-08-24%2013.12.57.mp4?dl=0 我开始研究它,使用 Leonids 库: https://github.com/plattysoft/Leonids 现在我制作了一个 particleSystem creator,并将其设置在我的发射器上,但该应用程序将始终从屏幕的 0,0(左上)点开始喷射粒子。 我怎样才能让它从我的视野中散发出来? 我是这样启动它的:

  new ParticleSystem(PSHiscoreAnimationActivity.this, 1000, R.drawable.icn_planning_dot, 10000)
            .setAcceleration(0.00013f, 90)
            .setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
            .setFadeOut(200, new AccelerateInterpolator())
            .emitWithGravity(emitter, Gravity.BOTTOM, 30);

这是我的布局:

<View android:id="@+id/emitter"
    android:layout_centerInParent="true"
    android:background="@color/blue"
    android:layout_width="10dp"
    android:layout_height="10dp" />

看来问题可能出在您启动它的地方。 参见 Issue #22 of the github project where someone else has the problem of the particles coming from the top left. If you are calling this from within onStart or onCreate it won't work properly because the views have not been measured yet and they suggest using a ViewTreeObserver as in this Whosebug answer