代码之家  ›  专栏  ›  技术社区  ›  codebot

如何将GraphView添加到android的Scroll窗格中?

  •  1
  • codebot  · 技术社区  · 11 年前

    我有一个 jjoe64 GraphView 。我试图将其添加到 HorizontalScrollView 。在此滚动视图中,我添加了 Relative Layout 然后 GraphView 但它不能滚动。这是我的xml,

            <HorizontalScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/horizontalScrollView"
                android:layout_alignParentBottom="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/textViewHR"
                android:fillViewport="true"
                android:layout_alignParentEnd="true">
    
                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_alignTop="@+id/horizontalScrollView">
    
                    <com.jjoe64.graphview.GraphView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:id="@+id/graph"
                        android:nestedScrollingEnabled="false" />
                </RelativeLayout>
            </HorizontalScrollView>
    

    我运行代码并尝试滚动。但它不能滚动。我怎样才能解决这个问题。

    提前感谢!

    1 回复  |  直到 11 年前
        1
  •  2
  •   Varil    11 年前

    HorizontalScrollView不是必需的。
    您需要更改视口的滚动度,如下所示:

    graphView = (GraphView) findViewById(R.id.graph);
    graphView.getViewport().setScrollable(true);
    

    看见 http://jjoe64.github.io/GraphView/javadoc/com/jjoe64/graphview/Viewport.html#setScrollable-boolean-