2013-06-05 73 views
1

虛線,虛線等中是否存在線條樣式?AndroidPlot:支持繪製虛線

我知道你可以添加/通過設置頂點顏色在這個例子空等清除了這一點:

LineAndPointFormatter blueFormat = new LineAndPointFormatter(Color.rgb(30,144,255), null, null); 

不過,我一直沒能找到一個快速的屬性設置,如「setDottedLine(真)「或某種程度上在javadoc。我想我可以每10分鐘繪製一個圖表,並在解析時每10分鐘下降一次,但這可能會比開銷多一點。

使用LineAndPointFormatter或設置其他一些小部件屬性是否有解決方法或竅門來創建虛線?

回答

5

想通了..

沒有爲LineAndPointFormatter構造:

setLinePaint(油漆)

所以畫虛線,那麼您需要使用像這樣的片段:

Paint dashPaint = new Paint(); 
dashPaint.setColor(getResources().getColor(R.color.red)); 
dashPaint.setStyle(Paint.Style.STROKE); 
dashPaint.setStrokeWidth(3); 
dashPaint.setPathEffect(new DashPathEffect(new float[] {10,5}, 0)); 
LineAndPointFormatter redDash = new LineAndPointFormatter(dashPaint.getColor(), null, null); 
redDash.setLinePaint(dashPaint); 
plot.addSeries(red,redDash); 
plot.redraw();