为什么我不能将MPAndroid饼图放在Fragment的某些视图上方?

时间:2018-11-21 13:38:13

标签: xml mpandroidchart

我正在使用MPAndroidChart库,而我只是想尝试应用here中的示例。

由于某些原因它无法正常工作,它崩溃并出现了一个熟悉的问题:bug report link

但是当我从android:layout_above="@+id/seekBar1" />的xml文件<com.github.mikephil.charting.charts.PieChart中删除此行时,一切正常,但我想将seekBar放在图表下方。

也许有一些解决方法?

任何人都可以解释一下为什么会发生这种情况。

编辑

这是另一个问题:我必须对图表使用wrap_content,否则它的尺寸会很小,并且如果我将layout_below应用于搜索栏-它也不会起作用,因为视图图表占据了整个屏幕。

完整的xml文件:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chartContentFrame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


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

    <SeekBar
        android:id="@+id/seekBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_marginBottom="35dp"
        android:layout_marginEnd="5dp"
        android:layout_marginRight="5dp"
        android:layout_toLeftOf="@+id/seekBarProgress"
        android:layout_toStartOf="@+id/seekBarProgress"
        android:paddingBottom="12dp" />

    <TextView
        android:id="@+id/seekBarProgress"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/seekBar"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="15dp"
        android:layout_marginEnd="10dp"
        android:layout_marginRight="10dp"
        android:gravity="right"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <include
        android:id="@+id/emptyChartView"
        layout="@layout/empty_chart_view" />
</RelativeLayout>

0 个答案:

没有答案