LinearLayout achartengine Chart not showing in ScrollView

I am trying to create an achartengine diagram in scrollview, but it will not display! It just shows a black screen, but not a glitch or something else. The fact is that if I just changed my tag to graphic displays, just fine. And in my Java code, I have renderer.setInScroll (true); for charting. Is this a problem with my xml?

Here is my xml:

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/trendchart" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" /> </LinearLayout> </ScrollView> 

(Currently, the only thing in ScrollView is a chart in which I plan to add more elements to make scrolling necessary, I just want it to be displayed first)

I also tried to display it with or without linearlayout wrapping, and this is the same result.

+8
android xml scrollview android-linearlayout achartengine
source share
4 answers

Under scrolling you should insert

 android:fillViewport="true" 
+10
source share

You will also need to make the following call, otherwise there will be display problems:

 renderer.setInScroll(true); 
+6
source share

Another solution is to provide size for your LinearLayout @ + id / trendchart:

eg:

 <LinearLayout android:id="@+id/trendchart" android:layout_width="fill_parent" android:layout_height="180dp" android:orientation="vertical" /> </LinearLayout> 

works great for me.

+2
source share

I tried the accepted answers, but none of them work for me. I solved the problem by adding

 chartView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 500)); 

But do not use chartView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)) ;
because for some reason it still doesn't display the chart. Hope this helps someone

+1
source share

All Articles