8

I want to show a PieChart in my fragment. Following is the xml I have written,

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background">

        <LinearLayout
            android:id="@+id/graphContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <com.github.mikephil.charting.charts.PieChart
                android:id="@+id/piechart"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>
   </ScrollView>

The problem is, PieChart is not working if I give match_parent or wrap_content. If i give fixed height and width it works fine. Also, if I remove the ScrollView , it works like a charm! So what needs to be done in case of ScrollView?

Shruti Dasgopal
  • 551
  • 4
  • 10

1 Answers1

-2

Add below attribute in scroll view

android:fillViewport="true"

Refer here

Community
  • 1
  • 1
Madasamy
  • 67
  • 7