Quick Start Guide
This guide will walk you through the minimum steps to get a pulse animation running in your Android application.
Step 1: Add the Dependency
First, make sure you have added Pulsator4Droid to your project as described in the Installation guide.
Step 2: Add PulsatorLayout to Your XML
The PulsatorLayout
acts as a container. Place it in your XML layout file and put any view you want to be at the center of the pulse inside it. The pulse animation will appear behind the child view.
Here is an example that places an ImageView
at the center of the pulsing effect:
<!-- res/layout/activity_main.xml -->
<pl.bclogic.pulsator4droid.library.PulsatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pulsator"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pulse_count="4"
app:pulse_duration="7000"
app:pulse_repeat="0"
app:pulse_color="@color/colorAccent"
app:pulse_startFromScratch="false"
app:pulse_interpolator="Linear">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_your_icon" />
</pl.bclogic.pulsator4droid.library.PulsatorLayout>
Step 3: Start the Animation in Code
Finally, get a reference to the PulsatorLayout
in your Activity or Fragment and call the start()
method.
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import pl.bclogic.pulsator4droid.library.PulsatorLayout;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PulsatorLayout pulsator = (PulsatorLayout) findViewById(R.id.pulsator);
pulsator.start();
}
}
That's it! You should now see a pulsing animation on your screen.