如何在 android 中将 GraphView 添加到滚动窗格中?
How to add GraphView into a Scroll pane in android?
我有一个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>
我 运行 代码并尝试滚动。但它不能滚动。我该如何解决这个问题。
提前致谢!
不需要 HorizontalScrollView。
您需要更改视口的可滚动性,如下所示:
graphView = (GraphView) findViewById(R.id.graph);
graphView.getViewport().setScrollable(true);
见http://jjoe64.github.io/GraphView/javadoc/com/jjoe64/graphview/Viewport.html#setScrollable-boolean-
我有一个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>
我 运行 代码并尝试滚动。但它不能滚动。我该如何解决这个问题。
提前致谢!
不需要 HorizontalScrollView。
您需要更改视口的可滚动性,如下所示:
graphView = (GraphView) findViewById(R.id.graph);
graphView.getViewport().setScrollable(true);
见http://jjoe64.github.io/GraphView/javadoc/com/jjoe64/graphview/Viewport.html#setScrollable-boolean-