codebot
codebot

Reputation: 2656

How to add GraphView into a Scroll pane in android?

I have a jjoe64 GraphView. I tried to add it into a HorizontalScrollView. In this scroll view I've added a Relative Layout and then GraphView in it. But It's cannot scrollable. Here is my 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>

I ran the code and tried to scroll. But it cannot be scrolled. How can I fix this.

Thanks in Advance!

Upvotes: 1

Views: 1556

Answers (1)

Varil
Varil

Reputation: 58

The HorizontalScrollView is not necessary.
You need to change the Scrollablility of your Viewport, like this:

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

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

Upvotes: 2

Related Questions