我已经添加了一个GraphView对象,并根据网站上的文档中的示例填充了一些数据。虽然我已经找到了如何更改GraphView的背景颜色,但我不知道如何更改网格颜色。有任何想法吗?
这是我尝试过的:
public void createGraph(View view){
GraphView graph = (GraphView) view.findViewById(R.id.graph);
GridLabelRenderer gridLabelRenderer = graph.getGridLabelRenderer();
// This works
graph.setBackgroundColor(getResources().getColor(android.R.color.holo_green_light));
// This does not work
gridLabelRenderer.setGridColor(getResources().getColor(android.R.color.holo_green_light));
// Nor does this
//gridLabelRenderer.setGridColor(15);
// This works
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
}
答案 0 :(得分:1)
试
graph.getGridLabelRenderer().reloadStyles();