Pulsator in Android: – There are some properties of Pulsator in Android

  • pulse_count : Number of pulse circles
  • pulse_duration : Duration in milliseconds of single pulse
  • pulse_repeat : Number of pulse repeats. Zero means INFINITE
  • pulse_color : ARGB pulse color
  • pulse_startFromScratch : Set to true if animation should start from the beginning
  • pulse_interpolator: Set interpolator type used for animation. Accepted values are "Linear", "Accelerate", "Decelerate", "AccelerateDecelerate"

First Add Dependency: –

compile 'pl.bclogic:pulsator4droid:1.0.3'

Example of Pulsator in Android: – Java File : – Pulsator1.java

package com.example.safal.sahilapp.pulsator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
import com.example.safal.sahilapp.R;
import java.util.Locale;
import pl.bclogic.pulsator4droid.library.PulsatorLayout;
public  class Pulsator1 extends AppCompatActivity {
private PulsatorLayout mPulsator;
private TextView mCountText;
private TextView mDurationText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pulsator);
mPulsator = (PulsatorLayout) findViewById(R.id.pulsator);
mPulsator.start();
}
private final SeekBar.OnSeekBarChangeListener mCountChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mPulsator.setCount(progress + 1);
mCountText.setText(String.format(Locale.US, "%d", progress + 1));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
private final SeekBar.OnSeekBarChangeListener mDurationChangeListener
= new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mPulsator.setDuration(progress * 100);
mDurationText.setText(String.format(
Locale.US, "%.1f", progress * 0.1f));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
}

 

Xml File: – activity_pulsator

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_pulsator"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<pl.bclogic.pulsator4droid.library.PulsatorLayout
android:id="@+id/pulsator"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pulse_count="10"
app:pulse_duration="5000"
app:pulse_repeat="0"
app:pulse_color="@color/colorAccent"
app:pulse_startFromScratch="false"
app:pulse_interpolator="Decelerate">

<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerInParent="true"
android:src="@drawable/cat" />

</pl.bclogic.pulsator4droid.library.PulsatorLayout>
</RelativeLayout>