Android Crosshair dotted/dashed lines


#1

Hi,

As per title, is it possible to customize the lines of the crosshair to appear dotted or dashed rather than continuous?


#2

Hi,

Thanks for getting in touch.

ShinobiCharts for Android offers a listener convenience method which allows you to intervene as the crosshair is about to be drawn and make changes. For reference the api docs for this method can be found here:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.OnCrosshairDrawListener.html#onDrawCrosshair(com.shinobicontrols.charts.ShinobiChart, android.graphics.Canvas, android.graphics.Rect, float, float, float, android.graphics.Paint)

Part of the solution then is to implement this method to draw your own crosshair circle and lines, modified to your requirements (in this case, with dashed lines). 

Unfortunately, a bug exists in Android which means that it is not as simple as using the Paint object’s own methods to tell the line to draw with a dashed pattern (for example, paint.setPathEffect(new DashPathEffect(new float[] {10,20}, 0))). Please see details of this bug here:

https://code.google.com/p/android/issues/detail?id=29944

Specifically this affects ShinobiCharts for Android as our use of OpenGL means that the HardwareAccelerated option must be set to true.

I believe a solution to your problem is to use View objects, to draw your lines in a dashed pattern. If you look at this blog post below, you will see an example of how to do this, albeit in a different context. 

(Please search for ‘createDottedLineView’.

I hope that you find this useful, please post back if you have any further questions.

Thanks and kind regards,

Kai.