为ImageView定位样式动画

时间:2016-04-19 09:14:28

标签: android android-animation

我正在尝试为ImageView创建一个动画,如下图所示(在Stackoverflow上收集)。 我想这样做是因为我希望它在我的位置定位时显示。我试图找到关键字,但我找不到任何东西。感谢。

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用 Wavedrawable 库。 它可以在GitHub中获得示例项目。

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);
    }

}