问题一:
无法画虚线
解决:
Paint xuLinePaint = new Paint();
xuLinePaint.setStyle(Paint.Style.STROKE);
xuLinePaint.setColor(Color.parseColor("#fc5a9c"));
PathEffect effects = new DashPathEffect(new float[]{5,5,5,5},1);
xuLinePaint.setPathEffect(effects);
path.moveTo(initPointX, initPointY); // from
path.lineTo(pointX, pointY); // to
canvas.drawPath(path, xuLinePaint);
问题二:不能初始化的时候就指定滑动的位置,无法滑动,用scrollTo()方法,滚动过的区域无法正常绘制了。真是纠结!
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//// chartView.scrollTo(-1000, 0);
if (todayPosition > 7) {
chartView.offsetLeftAndRight(-(70 * (todayPosition - 5)));
}
//// chartView.invalidate();
}
}, 500);
一定要等待绘制完毕后再执行,否则无效!