由网友(饿与想你都得忍着)分享简介:我发展我的应用程序一个简单的统计图形类。我试过aChartEngine和别人多,但我preFER用我自己的类。我画的图形Canvas类,包括Android的,但问题是,我不知道怎么填线与下边框之间的区域。眼下,该矩形不填充所有区域,很明显,你知道有什么解决办法?非常感谢。I'm developing a simple...
我发展我的应用程序一个简单的统计图形类。我试过aChartEngine和别人多,但我preFER用我自己的类。我画的图形Canvas类,包括Android的,但问题是,我不知道怎么填线与下边框之间的区域。眼下,该矩形不填充所有区域,很明显,你知道有什么解决办法?非常感谢。
I'm developing a simple statistical graphics class for my application. I've tried aChartEngine and others more, but I prefer use my own classes. I'm drawing the graphics with the Canvas class that includes Android, but the problem is that I don't know how to fill the area between the line and the bottom border. Right now, the rectangles don't fill all the area, obviously, do You know any solution? Thanks a lot.
推荐答案
使用一个 路径
,具有 涂料
有.setStyle(Paint.Style.FILL);调用。
Use a Path
, with a Paint
which has .setStyle(Paint.Style.FILL);
called.
Path fillPath = new Path();
fillPath.moveTo(0, 0); // Your origin point
fillPath.lineTo(x1, y1); // First point
// Repeat above line for all points on your line graph
fillPath.lineTo(xN, yN); // Final point
fillPath.lineTo(xN, 0); // Draw from final point to the axis ++
fillPath.lineTo(0, 0); // Same origin point
yourCanvas.drawPath(fillPath, /* Your paint */);
的 ++感谢 @TheCapn 这一点。的
++ Thanks to @TheCapn for this bit.
相关推荐
最新文章