Java 在Android中更改GraphView对象的网格颜色
我添加了一个GraphView对象,并按照网站文档中的示例用一些数据填充它。虽然我已经知道如何更改GraphView的背景颜色,但我不知道如何更改网格颜色。有什么想法吗 这就是我尝试过的:Java 在Android中更改GraphView对象的网格颜色,java,android,android-graphview,Java,Android,Android Graphview,我添加了一个GraphView对象,并按照网站文档中的示例用一些数据填充它。虽然我已经知道如何更改GraphView的背景颜色,但我不知道如何更改网格颜色。有什么想法吗 这就是我尝试过的: public void createGraph(View view){ GraphView graph = (GraphView) view.findViewById(R.id.graph); GridLabelRenderer gridLabelRenderer = graph.getGri
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);
}
public void createGraph(视图){
GraphView graph=(GraphView)view.findViewById(R.id.graph);
GridLabelRenderer GridLabelRenderer=graph.getGridLabelRenderer();
//这很有效
setBackgroundColor(getResources().getColor(android.R.color.holo_green_light));
//这行不通
setGridColor(getResources().getColor(android.R.color.holo_green_light));
//这也不是
//setGridColor(15);
//这很有效
LineGraphSeries=新的LineGraphSeries(新数据点[]){
新数据点(0,1),
新数据点(1,5),
新数据点(2,3),
新数据点(3,2),
新数据点(4,6)
});
图.addSeries(系列);
}
试试看
这里有一个样式示例
graph.getGridLabelRenderer().reloadStyles();