我添加了一个 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);
}
最佳答案
尝试
graph.getGridLabelRenderer().reloadStyles();
关于java - 在 Android 中更改 GraphView 对象的网格颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32085210/