Android MP Chart library get X-axis height

Viewed 73

Let's say I have an Activity containing a ChartView (blue rectangle)

enter image description here

Now, I want to place another View on top of it that will stretch from the X-axis all the way to the top of ChartView. I tried to do that by setting the margin-bottom equal to the height of the X-axis (red area), but I don't know how to get its height

enter image description here

How can I achieve this effect? Is there a way to get X-axis height in Android MP Chart? Or maybe there is a walkaround that will have a similar result? Desirable outcome (the gray area is a view placed on top of the chart):

enter image description here

1 Answers

chart.getXAxis().mLabelHeight returns the height of x-Axis by pixel. You can get it after OnGlobalLayoutListener, because it is calculated after x-Axis is drawn.

----------Updated Jun 22nd

another way is to use "getHeight() - mViewPortHandler.contentBottom()", but mViewPortHandler is protected, so an extended chart is necessary to provide access to mViewPortHandler

Related