MPAndroidChart PieChart在ScrollView中使用时不显示

MPAndroidChart PieChart在ScrollView中使用时不显示,android,android-layout,mpandroidchart,Android,Android Layout,Mpandroidchart,我想在片段中显示一个PieChart。 以下是我编写的xml <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background"> <LinearLayout android:id="@+id/graphCont

我想在片段中显示一个
PieChart
。 以下是我编写的xml

<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>


问题是,如果我给出
match\u parent
wrap\u content
,则
PieChart
不起作用。如果我给它固定的高度和宽度,它工作得很好。此外,如果我删除
滚动视图
,它会像一个符咒一样工作!那么,如果出现
滚动视图
,需要做什么呢?

在滚动视图中添加以下属性

android:fillViewport="true"

添加一个固定高度的piechart@PhilippJahoda:你读了整个问题了吗?是的,这是我的建议。我想这是你自己没有写过的自定义类;编写自定义类时,必须处理“初始化”对象的所有不同构造函数。可能是match_parent不会触发任何错误。你能在构造器中打印并检查它在视图中是否执行吗?@PhilippJahoda请指定高度?