Java 在Scrollview中进行Achartengine线形图平移
我正在开发一个Android应用程序,我必须在一个滚动视图中显示多个图形。现在,我得到了在scrollview上显示的折线图,我可以很好地滚动它们。然而,向上或向下平移图表似乎有问题。平移会结巴,而且会变得非常急促,实际上几乎无法使用 现在,我已经设置了renderer.setInScroll(true);其他一切似乎都很好(水平平移)。我认为这与scrollview干扰线状图的触摸事件有关,但我对Android还是太陌生了,我自己也弄不清楚 当我在谷歌上搜索时,我发现了一个关于类似问题的老话题: 主题中的人说他用这个解决了这个问题:但我无法将它应用于Achart 这是我的测试线图的相关代码。它在scrollview中设置为linearlayout(如果有任何区别,则在片段中):Java 在Scrollview中进行Achartengine线形图平移,java,android,achartengine,android-scrollview,pan,Java,Android,Achartengine,Android Scrollview,Pan,我正在开发一个Android应用程序,我必须在一个滚动视图中显示多个图形。现在,我得到了在scrollview上显示的折线图,我可以很好地滚动它们。然而,向上或向下平移图表似乎有问题。平移会结巴,而且会变得非常急促,实际上几乎无法使用 现在,我已经设置了renderer.setInScroll(true);其他一切似乎都很好(水平平移)。我认为这与scrollview干扰线状图的触摸事件有关,但我对Android还是太陌生了,我自己也弄不清楚 当我在谷歌上搜索时,我发现了一个关于类似问题的老话题
private xymultiplesseriesdataset getDemoDataset(){
XYmultiplesseriesdataset数据集=新的XYmultiplesseriesdataset();
最终int nr=80;
随机r=新随机();
对于(int i=0;i
简言之,问题是如何使平移在垂直滚动视图中正常工作?如果要在垂直滚动视图中放置多个图表,则xnl布局应如下所示
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rltMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ttl_bar"
android:contentDescription="@string/app_name" />
<ScrollView
android:id="@+id/scrlMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/chart"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart1"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart2"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart3"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart4"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
为什么它必须在scrollview中?因为我必须在同一菜单中显示多个图形,并让用户向下滚动查看它们。如何在此处绘制可滚动图形…有什么想法/建议吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rltMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ttl_bar"
android:contentDescription="@string/app_name" />
<ScrollView
android:id="@+id/scrlMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/chart"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart1"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart2"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart3"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_sel"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/chart4"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
double[] range = {0 , 5 , 0 , 5};
mRenderer.setMargins(marign);
mRenderer.setAxisTitleTextSize(axisTextSize);
mRenderer.setChartTitleTextSize(chartTextSize);
mRenderer.setLabelsTextSize(axisTextSize);
mRenderer.setLegendTextSize(legendTextSize);
// multiRenderer.setLegendHeight(40);
//when we dealing with one bar with one series , it is good to not deal with barSpacing() and setBarWidth()
//multiRenderer.setBarSpacing(-0.1);
//multiRenderer.setBarWidth((int)(context.getResources().getDimension(R.dimen.chart_bar_width)));
//multiRenderer.setBarWidth(50);
mRenderer.setAxesColor(Color.parseColor("#2c2c2c"));
mRenderer.setInitialRange(range, 1);
mRenderer.setXAxisMin(0.4);
mRenderer.setXAxisMax(6);
mRenderer.setXLabels(0);
//multiRenderer.setXAxisMax(15);
//multiRenderer.setYAxisMin(0);
mRenderer.setXLabelsAlign(Align.CENTER);
mRenderer.setYLabelsAlign(Align.RIGHT);
mRenderer.setPanEnabled(true,false);
mRenderer.setZoomEnabled(false, false);
mRenderer.setPanLimits(new double[]{0,18,0,0});
mRenderer.setApplyBackgroundColor(true);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setBackgroundColor(Color.argb(0x00, 0x01, 0x01, 0x01));
//multiRenderer.setMarginsColor(Color.parseColor("#FF000000"));
mRenderer.setXTitle(getxTItle());
mRenderer.setYTitle(getyTItle());
mRenderer.setXLabelsPadding(10);
mRenderer.setYLabelsPadding(10);
mRenderer.setXLabelsColor(Color.parseColor("#2c2c2c"));
mRenderer.setYLabelsColor(0, Color.parseColor("#2c2c2c"));
mRenderer.setLabelsColor(Color.parseColor("#2c2c2c"));
mRenderer.setShowCustomTextGridY(true);
mRenderer.setGridColor(Color.parseColor("#2c2c2c"));
mRenderer.setPointSize(20.5f);
mRenderer.setInScroll(true);