I am trying this new Konfetti View that shows Confetti on the screen, found here: https://github.com/DanielMartinus/Konfetti
I want this view to disappear after the Confetti stops falling, however with the code I have currently, the Konfetti View disappears before the Confetti even starts falling.
ConfettiActivity:
using System;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Text;
using Android.Views;
using Android.Widget;
using NL.DionSegijn.Konfetti;
using NL.DionSegijn.Konfetti.Models;
namespace ConfettiTest
{
[Activity(Label = "ConfettiActivity")]
public class ConfettiActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.confetti_activity);
KonfettiView konfettiView = (KonfettiView)FindViewById(Resource.Id.viewKonfetti);
int num = 0;
while (num != 2)
{
if (num == 0)
{
konfettiView
.Build()
.AddColors(Color.Yellow, Color.Green, Color.Magenta)
.SetDirection(0.0, 359.0)
.SetSpeed(1f, 5f)
.SetFadeOutEnabled(true)
.SetTimeToLive(4000L)
.AddSizes(new Size(12, 5f))
.StreamFor(400, 4000L);
}
else if (num == 1)
{
konfettiView.Visibility = ViewStates.Gone;
}
else
{
}
num++;
}
}
}
}
confetti_activity.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<nl.dionsegijn.konfetti.KonfettiView
android:id="@+id/viewKonfetti"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Confetti is finished"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/confettifinished"
android:textSize="50px"/>
</LinearLayout>
This answer :https://stackoverflow.com/a/6690607/13370965 won't work, cause in my proper code, I have more than 1 textview.
Another alternative is to put the konfettiView in the background, so you can see the textViews and the confetti at the same time, but I can't figure out how to this either.