1

I'm trying to create an animation for an ImageView which shows like picture below (collected on Stackoverflow). I want to do this because I want it shows when my location is locating. I've tried to find keywords but i couldn't found anything. Thanks.

enter image description here

Harry T.
  • 3,478
  • 2
  • 21
  • 41
  • I don't know how to animate it with gradient. I've tried by using some white circles with duration 1sec, alpha 0 -> 1, repeatCount infinite. But it doesn't seem smooth. – Harry T. Apr 19 '16 at 09:21

1 Answers1

1

You can use Wavedrawable Library. it is available in GitHub with sample projects.

https://github.com/Alexrs95/WaveDrawable

compile 'me.alexrs:wave-drawable:1.0.0'

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import me.alexrs.wavedrawable.WaveDrawable;


public class MainActivity extends Activity {
 private WaveDrawable waveDrawable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageView imageView = (ImageView) findViewById(R.id.image);
 waveDrawable = new WaveDrawable(Color.parseColor("#8e44ad"), 500);
        imageView.setBackgroundDrawable(waveDrawable);
interpolator = new LinearInterpolator();
 waveDrawable.setWaveInterpolator(interpolator);
        waveDrawable.startAnimation();
 }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
Mr Robot
  • 1,747
  • 6
  • 35
  • 67
  • I can see that github source is exactly my image come from! But anyhow we can code it instead of using library? I want to learn too, but I can only understand simple code lines. – Harry T. Apr 19 '16 at 09:25
  • 1
    Thanks for your first answer. I'll check the 2nd one later. – Harry T. Apr 19 '16 at 09:49