滚动视图不滚动图表

时间:2014-12-22 02:33:36

标签: java android xml scrollview achartengine

在尝试将滚动视图与Android中的图表放在一起时,我遇到了一些问题。对于图表,我使用的是achartengine插件。这是我的xml布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:id="@+id/scrollViewChartLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">
<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/txtDisplayAttendeeAmt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingRight="10dp"
        android:text="0"
        android:textColor="@color/lightorange"
        android:textSize="35dp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:text="people joined." />
</LinearLayout>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal"
    android:weightSum="1" >

    <TextView
        android:id="@+id/txtDisplayPctMale"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.35"
        android:gravity="right"
        android:paddingRight="8dp"
        android:text="0 %"
        android:textColor="@color/lightblue"
        android:textSize="35dp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.15"
        android:paddingTop="10dp"
        android:text="Male" />

    <TextView
        android:id="@+id/txtDisplayPctFemale"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.35"
        android:gravity="right"
        android:paddingRight="8dp"
        android:text="0 %"
        android:textColor="@color/lightpink"
        android:textSize="35dp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.2"
        android:paddingTop="10dp"
        android:text="Female" />
</LinearLayout>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />

<LinearLayout
    android:id="@+id/chart_racesPie"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="5dp" >
</LinearLayout>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textview_lightgrey_border" />
</LinearLayout>

</ScrollView>

我有多个图表放在一个活动中,所以我必须使用滚动视图。但是,滚动视图不起作用。有什么想法吗?

如果我从scrollview中删除了android:fillViewport =“true”并将其高度设置为fill_parent,则图表是不可见的。

提前致谢。

2 个答案:

答案 0 :(得分:1)

ScrollView只能有一个孩子。

答案 1 :(得分:0)

我测试了你当前的代码。刚刚更改为ScrollView

来自:

android:layout_height="fill_parent"

收件人:`

android:layout_height="wrap_content"

如果内容超出当前屏幕尺寸,则可以滚动。

谢谢。