如何使域网格线滚动

时间:2014-06-09 03:41:07

标签: androidplot

AndroidPlot是一个很棒的库。 我跟着http://androidplot.com/docs/how-to-pan-zoom-and-scale/制作了一个可滚动的图表,但发现图表滚动时域网格线是固定的。是否可以使网格线与图表一起滚动?

由于

2 个答案:

答案 0 :(得分:0)

查看this similar question - 它包含指向您所需内容的示例源的链接。

答案 1 :(得分:0)

我将图表包裹在线性布局中:

 <LinearLayout
    android:id="@+id/graphLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.androidplot.xy.XYPlot
        android:id="@+id/mySimpleXYPlot"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        ....

然后在.java文件中,我将视图分配给线性布局,并将onTouchListener设置为该布局:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    LinearLayout view = (LinearLayout) findViewById(R.id.graphLayout);  // assign layout graph is in
    view.setOnTouchListener(this);       // set onTouchListener to graph's layout     

    plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
    ....

这对我有用。