在android中绘制图形
问题描述:
我可以使用html或html5绘制活动图形并使用webview或其他东西在android活动中显示它吗? 如果有可能,请告诉我如何处理它。 任何教程将是最佳做法。 在此先感谢。在android中绘制图形
答
您可以选择使用图书馆,如achartengine。你也可以在android中做canvas绘图。此外,您可以使用HTML进行画布绘制,并像上面提到的那样在webview中显示它。
这一切都取决于你愿意采取什么级别的复杂性,以及什么是真正需要的。如果你需要显示一个简单的图形,你总是可以使用自定义类并使用onDraw方法来进行画布绘制。
答
但是,请注意,您还可以做离线图表和还指出,这是不使用HTML5来完成。 要使用HTML创建图表,请参阅此tutorial。
GraphView graphView = new GraphView(
this
, new GraphViewData[] {
new GraphViewData(1, 2.0d)
, new GraphViewData(2, 1.5d)
, new GraphViewData(2.5, 3.0d) // another frequency
, new GraphViewData(3, 2.5d)
, new GraphViewData(4, 1.0d)
, new GraphViewData(5, 3.0d)
}
, "GraphViewDemo"
, null
, null
);
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);