Skip to content

Particles without onclick call Example #22

@leglopy

Description

@leglopy

Hey,

I'm using this wonderful library but i'm blocked to animate particles without a touch on a button.

I have a Xml view with

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"  tools:context=".MainActivity"
    >
    <FrameLayout
        android:id="@+id/background_hook"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <TextView
        android:id="@+id/button"
        android:text="Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
...
</RelativeLayout>

And an actvity with

   @OnClick(R.id.button)
    public void buttonTouched(View v){
            doAnimation();
   }

 public void doAnimation(){
            ParticleSystem ps = new ParticleSystem(this, 50, R.drawable.placeholder, 1000, R.id.background_hook);
            ps.setSpeedRange(0.1f, 0.25f);
            ps.setScaleRange(0.7f, 1.3f);
            ps.setSpeedRange(0.1f, 0.25f);
            ps.setAcceleration(0.0001f, 90);
            ps.setRotationSpeedRange(90, 180);
            ps.setFadeOut(200, new AccelerateInterpolator());
            ps.emit(v, 100);
 }

That code is okay. I have particles around the button.
But if i start the animation programatically without onclick event I have the animation in the top left corner --'

 protected void onStart() {
            super.onStart();
            doAnimation();
    }

It's the same with

 protected void onStart() {
            super.onStart();
            button.performClick();
    }

Thank you in advance for any help you can provide

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions