Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我需要制作粒子动画,但粒子总是从像素0,0开始_Android_Animation_Ondraw_Particles_Particle System - Fatal编程技术网

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

Android 我需要制作粒子动画,但粒子总是从像素0,0开始,android,animation,ondraw,particles,particle-system,Android,Animation,Ondraw,Particles,Particle System,这是我需要制作的动画: 我开始使用Leonids图书馆进行研究: 现在我制作了一个particleSystem creator,并将其设置在我的发射器上,但该应用程序将始终从屏幕左上角的0,0点开始飞溅粒子。 如何使其从我的视图中发射? 我就是这样开始的: new ParticleSystem(PSHiscoreAnimationActivity.this, 1000, R.drawable.icn_planning_dot, 10000) .setAccelerat

这是我需要制作的动画: 我开始使用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" />

看来问题可能出在你发起的地方。
查看其他人在哪里遇到来自左上角的粒子问题。如果您在onStart或onCreate中调用此函数,它将无法正常工作,因为尚未测量视图,他们建议使用ViewTreeObserver,如中所示

谢谢,它在我的onCreate中,将尝试移动代码并查看接下来发生的情况。我会让你知道,一旦我设法使其工作再次感谢,它的工作,如果我使用ViewTreeObserver不包括链接,你打算删除,一旦你得到你的答案