【问题标题】:Positioning / Setting Direction of Confetti AndroidConfetti Android 的定位/设置方向
【发布时间】: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

任何关于如何使五彩纸屑来自顶部的帮助将不胜感激。提前谢谢!

【问题讨论】:

标签: android kotlin direction


【解决方案1】:

试试这个:

.setPosition(-50f, konfettiView.getWidth() + 50f, -50f, -50f)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-30
    • 2016-01-06
    • 2015-02-11
    • 1970-01-01
    • 2020-07-25
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多