android - 如何使图表适合android上的布局

标签 android achartengine

我是 Android 和 AChartengine 的新手,我正在做我的项目。

假设我有这样的布局:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<LinearLayout
     android:id="@+id/displayECG"
     android:layout_width="fill_parent"
     android:layout_height="100px"
    android:orientation="horizontal" >

</LinearLayout>

在 MainActivity.java 中,我的代码如下:

view = ChartFactory.getLineChartView(this, dataSet, renderer);
LinearLayout layout = (LinearLayout) findViewById(R.id.displayECG);
layout.addView(view, new LayoutParams(LayoutParams.MATCH_PARENT,    LayoutParams.MATCH_PARENT));

但是当我运行我的应用程序并得到一个图形时,它比布局空间小得多。我想要一个图表,它适合我的布局,那么我该怎么做呢?

谢谢,

最佳答案

您的图表实际上填满了整个布局,但默认情况下 AChartEngine 有很多附加功能已打开。我建议在创建图表之前添加以下几行:

renderer.setLegendHeight(1);
renderer.setZoomButtonsVisible(false);
renderer.setMargins(new int[] {0, 0, 0, 0});

您可能还需要其他一些东西,但这至少应该让您入门。此外,您的 displayECG 只有 100 像素高。这也可能是有限的。

关于android - 如何使图表适合android上的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23408748/

相关文章:

android - android中的Achart引擎自定义点样式

android - 使用 cordova-plugin-ionic-webview 版本冲突?

android - RelativeLayout 的旋转如何在 android 中工作?

android - AchartEngine XYchart背景颜色问题

安卓 AChartEngine : SalesComparisonChart lines do not reach the exact value

java - 调用图表引擎图表时 Android 应用程序崩溃

Java,更改字体和文本颜色。

Android如何在屏幕上显示通知

android - Android 和 Chrome 浏览器上的 Openlayers - 使用视口(viewport)元标记时出现白线

android - 如何在 Donut-achartEngine Graph 中设置图像?