0

肯定有关于这个问题的问题,但我发现的相关问题都没有解决我的问题。所以。

我有以下场景,我想要一个可以向下滚动到我将拥有的倍数图表的屏幕。像这张图片代表这里

现在,使用下面的代码,我得到了这个结果

所以,发生的事情是两个图表都在彼此上,我不知道为什么。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/mainLayout">

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/secondLayout">

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

            <com.github.mikephil.charting.charts.BarChart
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/barChart"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentBottom="true" />

        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

我正在使用 MPAndroidchart 库。

谢谢。

4

2 回答 2

1

试试这个修改版本

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/secondLayout">          


        <com.github.mikephil.charting.charts.PieChart
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="24dp"
            android:id="@+id/pieChart" />

        <com.github.mikephil.charting.charts.BarChart
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/barChart"
            android:layout_below="@+id/pieChart"              
            android:layout_marginTop="48dp"
            android:layout_centerHorizontal="true" />

    </RelativeLayout>
</ScrollView>

</RelativeLayout>
于 2016-03-03T23:56:05.047 回答
0

这个问题不清楚,你的问题到底是什么?如果您的意思是您的图表在彼此上,请尝试使用具有垂直方向的 LinearLayout 而不是您的第二个 RelativeLayout。

于 2016-03-03T23:58:38.047 回答