如何设置在Android的achartengine线图的背景图像? [英] How to set the background image for achartengine line chart in android?
问题描述
我使用achartengine到dispaly线图中我application.I需要添加背景图片图表,但是当我在XML中设置背景图片,它不工作。有没有人试过吗?先谢谢了。
I am using achartengine to dispaly the line chart in my application.I need to add the bg image for the chart , but when I set the bg image in xml , its not working. Have anyone tried this? Thanks in advance.
推荐答案
首先,您需要添加图表插入到你的活动,并设置preferred图片作为背景的活动布局。 (看看XYChartBuilder在AChartEngineneDemo来看看如何做到这一点)
Firstly, you need to add chart into your activity, and set preferred image as background in activity layout. (Take a look at XYChartBuilder in AChartEngineneDemo to see how to do that)
其次,设置透明的背景图和图表保证金:
Secondly, set transparent background for chart and chart margin:
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.TRANSPARENT);
mRenderer.setMarginsColor(getResources().getColor(R.color.transparent_background));
最后,创建自己的透明背景,因为Color.TRANSPARENT不适合图表保证金工作:
Finally, create your own transparent background since the Color.TRANSPARENT doesn't work for chart margin:
<color name="transparent_background">#00FF0000</color>
希望这有助于:)
Hope this helps :)
这篇关于如何设置在Android的achartengine线图的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!