android - ScrollView not working with aChartEngine -
i trying put multiple charts on single activity, , use scrollview view them all.
the first 2 charts showing second 2 not. have followed instructions tutorials, , have followed suggestions on stack, none of them work.
i have tried removing scrollview, charts still not displaying. appreciated.
xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" > <scrollview android:layout_width="wrap_content" android:layout_height="wrap_content" android:fillviewport="true" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <linearlayout android:id="@+id/chart" android:layout_width="fill_parent" android:layout_height="300dp" android:orientation="horizontal" /> <linearlayout android:id="@+id/chart1" android:layout_width="fill_parent" android:layout_height="300dp" android:layout_below="@id/chart" android:orientation="horizontal" /> <linearlayout android:id="@+id/chart2" android:layout_width="fill_parent" android:layout_height="300dp" android:layout_below="@id/chart1" android:orientation="horizontal" /> <linearlayout android:id="@+id/chart3" android:layout_width="fill_parent" android:layout_height="300dp" android:layout_below="@id/chart2" android:orientation="horizontal" /> </linearlayout> </scrollview> </relativelayout>
linegraph.java
public class linegraph extends activity{ xymultipleseriesdataset dataset = new xymultipleseriesdataset(); xymultipleseriesrenderer mrenderer = new xymultipleseriesrenderer(); protected static graphicalview mchartview; public graphicalview getview(context context, int[]z, int []zz){ categoryseries series = new categoryseries("line1"); for(int i=0;i<z.length;i++){ series.add("bar " + (i+1),z[i]); } categoryseries series2= new categoryseries("demo"); for(int i=0;i<zz.length;i++){ series2.add("bar " + (i+1),zz[i]); } xymultipleseriesdataset dataset = new xymultipleseriesdataset(); dataset.addseries(series.toxyseries()); dataset.addseries(series2.toxyseries()); xymultipleseriesrenderer mrenderer = new xymultipleseriesrenderer(); mrenderer.setaxescolor(color.green); xyseriesrenderer renderer = new xyseriesrenderer(); renderer.setdisplaychartvalues(true); renderer.setchartvaluesspacing((float)0.5); mrenderer.addseriesrenderer(renderer); mrenderer.setzoomenabled(false); mrenderer.setpanenabled(false); mrenderer.setzoomrate(6.0f); mrenderer.setshowlabels(true); mrenderer.setfitlegend(true); mrenderer.setinscroll(true); xyseriesrenderer renderer2 = new xyseriesrenderer(); renderer.setcolor(color.cyan); renderer.setdisplaychartvalues(true); mrenderer.addseriesrenderer(renderer2); return chartfactory.getlinechartview(context, dataset, mrenderer); } }
mainactivity:
public class mainactivity extends linegraph { int a[] ={1,2,3}; int b[] ={4,5,6}; int c[] ={7,8,9}; int d[] ={10,11,12}; int e[] ={13,14,15}; int f[] ={16,17,18}; int g[] ={19,20,21}; int h[] ={22,23,24}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); linegraphhandler (); } public void linegraphhandler (){ linegraph line = new linegraph(); graphicalview gview = line.getview(this, a,b); graphicalview gv = line.getview(this,c,d); graphicalview gv2 = line.getview(this,e,f); graphicalview gv3 = line.getview(this,g,h); linearlayout layout = (linearlayout) findviewbyid(r.id.chart); layout.addview(gview); linearlayout layout2 = (linearlayout) findviewbyid(r.id.chart1); layout2.addview(gv); linearlayout layout3 = (linearlayout) findviewbyid(r.id.chart2); layout2.addview(gv2); linearlayout layout4 = (linearlayout) findviewbyid(r.id.chart3); layout2.addview(gv3); } }
use scroll view parent layout rather relative layout
Comments
Post a Comment