MPAndroidChart PieChart 在 ScrollView 中使用时不显示 [英] MPAndroidChart PieChart is not displayed when used inside ScrollView

查看:56
本文介绍了MPAndroidChart PieChart 在 ScrollView 中使用时不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

问题是,如果我给 match_parentwrap_contentPieChart 不起作用.如果我给出固定的高度和宽度,它就可以正常工作.此外,如果我删除 ScrollView ,它就像一个魅力!那么遇到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?

推荐答案

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

Add below attribute in scroll view

android:fillViewport="true"

参考这里

这篇关于MPAndroidChart PieChart 在 ScrollView 中使用时不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆