2014-06-09 43 views

回答

0

看看this similar question - 它包含一個鏈接到你想要做什麼的例子源。

+1

感謝Nick,我的意思是,當左右滾動時,域標記線(標記X軸上的值的垂直線)是固定的,每個線的值在滾動期間更新。現在我想要的是,讓這些線條在滾動時隨着圖表一起移動,並保持每行的值不變。 –

+0

在這種情況下,我知道這樣做的唯一方法就是將圖塊嵌入到ScrollView中。由於潛在的性能問題,我不是這種方法的粉絲,但如果你不繪製數千個點,它可以工作。 – Nick

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); 
    .... 

即爲我工作。