Android : Add shinobiChart in scrollView


#1

Hello,

I want to put a chart in a scrollview but my chart is never visible.

How can i solve my problem please ?

Thx  :grin:


#2

Hi beli63,

We don’t know of any problems with displaying ShinobiCharts in Scrollviews. Could you perhaps tell us what you have tried so far, so that we can try and work out the problem that you are experiencing.

Cheers,
Joel


#3

Hi Joel,

I put my XML in the post.

I just see the legend when i put the chartFragment in a scrollView.

The legend position is Bottom_Middle

<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:background="@color/white"
    tools:context=".activities.ChartDetailsActivity" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="15dp"
        android:paddingRight="15dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <fragment
                class="com.shinobicontrols.charts.ChartFragment"
                android:id="@+id/chart"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>
    </ScrollView>

    <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:layout_centerInParent="true"
        android:visibility="visible"/>

</RelativeLayout>

#4

Hi beli63,

The issue that you are seeing is a product of some of the nuances of ScrollViews. You can find out more information about those nuances in this blog post by Romain Guy, one of the Android engineers at Google. For your case in particular, all you need to do is to change the layout_height of your ScrollView to “match_parent” and add  android:fillViewport=“true”  to your ScrollView.

This should solve your issue but if you have any other questions then don’t hestitate to ask.

Joel