自定义view 三角形路径绘制
来源:互联网 发布:端口号80是什么意思 编辑:程序博客网 时间:2024/05/29 17:41
package com.sero.vk.signNow.ViewBezier;import android.animation.ValueAnimator;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.DashPathEffect;import android.graphics.Paint;import android.graphics.Path;import android.graphics.PathEffect;import android.graphics.PathMeasure;import android.util.AttributeSet;import android.view.View;import android.view.animation.LinearInterpolator;/** * Created by Administrator on 2017/3/1. */public class MyPathTracingView extends View implements View.OnClickListener { private Paint paint; private Path path; private PathMeasure pathMeasure; private float length; private float mAnimationValue; private PathEffect pathEffect; public MyPathTracingView(Context context) { super(context); } public MyPathTracingView(Context context, AttributeSet attrs) { super(context, attrs); paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(3); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); path = new Path(); path.moveTo(100, 100); path.lineTo(100, 500); path.lineTo(400, 300); path.close(); pathMeasure = new PathMeasure(); pathMeasure.setPath(path,true); length = pathMeasure.getLength(); ValueAnimator animator = ValueAnimator.ofFloat(1, 0); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setDuration(2000); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mAnimationValue = (float) animation.getAnimatedValue(); pathEffect = new DashPathEffect(new float[]{length, length}, length * mAnimationValue); paint.setPathEffect(pathEffect); invalidate(); } }); animator.start(); } public MyPathTracingView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawPath(path, paint); } @Override public void onClick(View v) { }}
0 0
- 自定义view 三角形路径绘制
- andriod自定义View绘制形, 圆形, 三角形,...
- 三角形的自定义View
- 自定义view的绘制
- 自定义view 的绘制
- 自定义view--绘制图形
- 自定义view绘制几何图形
- 自定义view绘制时钟
- 自定义View绘制文字
- 自定义view-绘制统计图
- 如何自定义绘制View
- 自定义View绘制基础
- 自定义view绘制太极图
- 自定义View绘制五星红旗
- 自定义View绘制时钟
- 自定义View绘制形, 圆形, 三角形, 扇形, 椭圆, 曲线,文字和图片的坐标讲解
- Android自定义View 路径绘制、涂鸦签名的路径数据获取
- 绘制圆角三角形的View
- [BZOJ1965][Ahoi2005]SHUFFLE 洗牌(数学相关)
- Android studio打jar包
- 添加div弹框 + 遮罩
- Android ScrollView撑不满屏幕的解决方案
- Struts2(三) 数据在框架中的数据流转问题
- 自定义view 三角形路径绘制
- (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to address 0.0.0.0:X
- oracle authid current_user详解
- NHibernate 查询视图数据与数据库数据不一致
- Other Linker Flags 中加入-ObjC或者-all_load 作用
- 电量变化
- H5项目常见问题汇总及解决方案
- sql server 安装
- Java 性能优化系列之3.1[JVM调优]