Github地址:https://github.com/nuptboyzhb/WaterWaveView

欢迎Fork。欢迎Star

1.先看效果

android:模拟水波效果的自己定义View_android开发

2.再看关键代码

描绘函数y = Asin(wx+d)+offset

/**
* 使用路径描绘绘制的区域
*
* @return
*/
private Path getFristWavePath() {
// 绘制区域1的路径
if (firstWavePath == null) {
firstWavePath = new Path();
}
firstWavePath.reset();
firstWavePath.moveTo(0, height);// 移动到左下角的点
for (float x = 0; x <= width; x += X_STEP) {
float y = (float) (waveHeight * Math.sin(omega * x + moveWave) + waveHeight)
+ heightOffset;
firstWavePath.lineTo(x, y);
}
firstWavePath.lineTo(width, 0);
firstWavePath.lineTo(width, height);
return firstWavePath;
}