波浪线,水波纹

匿名 (未验证) 提交于 2019-12-02 23:26:52

自定义View

package gg.bw.com.wangshu20190404;  import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.util.AttributeSet; import android.view.View;  public class WaterView2 extends View {     Paint paint = new Paint();      Path path = new Path();     float mt;     public WaterView2(Context context) {         super(context);         paint.setAntiAlias(true);     }      public WaterView2(Context context,  AttributeSet attrs) {         super(context, attrs);     }      @Override     protected void onDraw(Canvas canvas) {         super.onDraw(canvas);         path.reset();         path.moveTo(getLeft(),getBottom());          float v = (float) (Math.PI *2/ getRight());          mt-=0.1;         for (int i = 0; i <=getRight() ; i+=20) {             path.lineTo(i, (float) (10 * Math.cos(v * i +mt)+ 10));         }         path.lineTo(getRight(),getBottom());          canvas.drawPath(path,paint);         postInvalidateDelayed(20);       } }  
文章来源: https://blog.csdn.net/weixin_44405056/article/details/89064776
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!