如何设置图表大小的achartengine [英] How to set chart size in achartengine

查看:365
本文介绍了如何设置图表大小的achartengine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,有一个的LinearLayout一个活动,我把我的表到这个:

I have an activity that has a LinearLayout and I put my chart into this:

...
mChart = ChartFactory.getCubeLineChartView(this, mDataset, mRenderer, 0.3f);
graphActivityLayout.addView(mChart, 1);

这填补了我的整个布局。如何指定图表的尺寸是多少?我还没有找到任何办法做到这一点。

This fills up my whole layout. How can I specify the dimensions of the chart? I haven't found any ways to do it.

如果mChart我的 onResume 方法检查为null,如果不是,则调用重绘就可以了,否则设置图表数据并执行上面的代码片段。没有什么是与我的问题。

My onResume method check if the mChart is null and if not, then calls repaint on it, otherwise sets up the chart data and does the above snippet. Nothing that is related to my question.

推荐答案

据我所知,图表视图具有设置为FILL_PARENT为默认布局尺寸。这个一般吃了线性布局的所有空间,并揣在相同的布局其他意见。
如果你在布局(我猜在位置0从code段),其布局宽度/高度设置为WRAP_CONTENT只是另外一个观点,就足够了设定任意的非零重量图表视图。这告诉线性布局,利用剩余的空间,而不是使用所有的空间:

As far as I know, the chart view has layout dimensions set to "FILL_PARENT" as default. This in general eats up all the space of a linear layout and hides the other views in the same layout. If you have just one other view in the layout (I guess at position 0 from your code snippet), which has the layout-width/height set to "WRAP_CONTENT", it is sufficient to set an arbitrary non zero weight for the chart view. This tells the linear layout to use the remaining space, rather than to use all space:

graphActivityLayout.addView(mChart, 1);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mChart.getLayoutParams();
layoutParams.weight = 1; 

这篇关于如何设置图表大小的achartengine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆