Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinearLayout achartengine Chart not displaying in ScrollView

I'm trying to create an achartengine chart within a scrollview but it won't display! It just shows a black screen, but doesn't crash or anything. The thing is if I just change my tag to the chart displays just fine. And in my Java code I do have renderer.setInScroll(true); for the charts renderer. Is this an issue 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 the ScrollView is the chart I plan to add more elements to make scrolling necessary, I just want it to display first)

Also I have tried to display it both with and without the wrapping linearlayout and it is the same result.

like image 722
VinC Avatar asked Jul 23 '12 17:07

VinC


3 Answers

Under the scrollview you have to insert

android:fillViewport="true"
like image 142
VinC Avatar answered Sep 24 '22 16:09

VinC


You will also have to do the following call, otherwise there will be display issues:

renderer.setInScroll(true);
like image 37
Dan D. Avatar answered Sep 24 '22 16:09

Dan D.


Other solution is to give a size for your LinearLayout @+id/trendchart:

for example:

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

works fine for me.

like image 33
Oleksandr Bodashko Avatar answered Sep 23 '22 16:09

Oleksandr Bodashko