我正在为我的应用程序开发一个简单的统计图形类。我尝试过 aChartEngine 和其他更多,但我更喜欢使用我自己的类。
我正在使用包含 Android 的 Canvas 类绘制图形,但问题是我不知道如何填充线条和底部边框之间的区域。
现在,矩形显然没有填充所有区域,您知道有什么解决方案吗?多谢。
Use a Path http://developer.android.com/reference/android/graphics/Path.html,有一个Paint http://developer.android.com/reference/android/graphics/Paint.html其中有.setStyle(Paint.Style.FILL); http://developer.android.com/reference/android/graphics/Paint.html#setStyle(android.graphics.Paint.Style) 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 https://stackoverflow.com/users/804773/thecapn为了这一点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)