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