【发布时间】:2021-07-31 16:41:38
【问题描述】:
我正在开发一个安卓应用程序。我已经实现了以下库:
nl.dionsegijn:konfetti:1.3.2。这个库允许您显示五彩纸屑,但我有一个小问题。我试图让五彩纸屑来自顶部,但它只来自左上角。请参阅下面的屏幕截图。
这是我的 xml 布局文件中的代码:
<nl.dionsegijn.konfetti.KonfettiView
android:id="@+id/viewKonfetti"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</nl.dionsegijn.konfetti.KonfettiView>
这是我的 kotlin 文件中的代码:
viewKonfetti.build()
.addColors(Color.parseColor("#FFD700"), Color.parseColor("#FD7F20"))
.setDirection(0.0, 359.0)
.setSpeed(1f, 5f)
.setFadeOutEnabled(true)
.setTimeToLive(2000L)
.addShapes(Shape.Square, Shape.Circle)
.addSizes(Size(12))
.streamFor(500, StreamEmitter.INDEFINITE)
here is the link to the github repository of this library
任何关于如何使五彩纸屑来自顶部的帮助将不胜感激。提前谢谢!
【问题讨论】:
-
您自己浏览过那个库吗?
setPosition似乎很相关:github.com/DanielMartinus/Konfetti/blob/…