Android约束Yout粒子动画高程

Android约束Yout粒子动画高程,android,xml,layout,kotlin,foreground,Android,Xml,Layout,Kotlin,Foreground,我有一个大问题,我试图把粒子动画放在背景中 我正在使用图书馆: Confettis的动画完美地出现在我的屏幕上,但它位于前景,我希望它位于ImageView后面的背景上 我尝试设置ImageView的高度,但动画仍停留在前景中 我的SplashScreen.xml带有Constraintlayout: <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/

我有一个大问题,我试图把粒子动画放在背景中 我正在使用图书馆:

Confettis的动画完美地出现在我的屏幕上,但它位于前景,我希望它位于ImageView后面的背景上

我尝试设置ImageView的高度,但动画仍停留在前景中

我的SplashScreen.xml带有Constraintlayout:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bg_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_splashscreen">


<ImageView
    android:id="@+id/logo_text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="36dp"
    android:layout_marginStart="37dp"
    android:layout_marginTop="8dp"
    android:src="@drawable/logo"
    android:elevation="4dp"
    app:layout_constraintBottom_toTopOf="@+id/guideline2"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintHorizontal_weight="0.1"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline"
    app:layout_constraintVertical_weight="0.1"
    tools:ignore="ContentDescription" />

<android.support.constraint.Guideline
    android:id="@+id/guideline"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="0.26371" />

<android.support.constraint.Guideline
    android:id="@+id/guideline2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="0.42074" />
</android.support.constraint.ConstraintLayout>
编辑:我认为我理解ConstraintLayout中的层次结构是:最后创建的内容与之前创建的其他元素相比位于前景,因此可以解释为什么动画与ImageView相比位于前景

但是我怎么才能解决这个问题呢? 希望这足够清楚,谢谢

我找到了解决办法

必须向ParticleSystem调用添加其他参数,如下所示:

ParticleSystem(fromActivity, 80, R.drawable.confetti, 10000, R.id.YOURID)
        .setSpeedModuleAndAngleRange(0f, 0.3f, 0, 0)
        .setRotationSpeed(144f)
        .setAcceleration(0.00035f, 100)
        .emit(100, -100, 5)
然后将以下内容添加到XML文件中ConstraintsLayout的开头:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/YOURID">
</FrameLayout>


就这样

我不明白这些指导方针对你的情况有什么作用(为什么?),但除此之外,我也不明白;'我不明白你想要粒子在哪里,在什么后面?你的布局中只有一个图像视图。这在我的整个项目中对我很有用,但没关系。我希望粒子位于图像视图后面,但现在没事了,我解决了为什么不;'您是否为根约束布局指定一个ID,并使用该ID而不是添加一个FrameLayout?此外,您不应该在约束布局中添加小部件并使用
match\u parent
。ConstraintLayout不是这样工作的。我尝试使用根ConstraintLayout:android=“@+Id/bg_splash”的Id,但它不起作用。在这种情况下,我建议您不要使用match_parent,使用0dp并指定约束。
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/YOURID">
</FrameLayout>