写在前面
本文属于部分原创,实现安卓平台正弦曲线类报表绘制功能介绍,基于网络已有的曲线报表绘制类(LineGraphicView)自己添加了涨潮的渐变动画算法
最终效果图
废话少说,直接上源码
一、自定义View LineGraphicView,本类注释不算多,能搜到这篇文章的朋友看懂代码应该不会有障碍
import java.util.ArrayList;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Transformation;
class LineGraphicView extends View {
/**
* 公共部分
*/
private static final int CIRCLE_SIZE = 10;
private static int yPos = 0;
private float aniProgress;// 实现动画的值
private HistogramAnimation ani;
private static enum Linestyle {
Line, Curve
}
private Context mContext;
private Paint mPaint;
private Resources res;
private DisplayMetrics dm;
/**
* data
*/
private Linestyle mStyle = Linestyle.Curve;
private int canvasHeight;
private int canvasWidth;
private int bheight = 0;
private int blwidh;
private boolean isMeasure = true;
/**
* Y轴最大值
*/
private int maxValue;
/**
* Y轴间距值
*/
private int averageValue;
private int marginTop = 10;
private int marginBottom = 40;
/**
* 曲线上总点数
*/
private Point[] mPoints;
/**
* 纵坐标值
<