Div_D Div_D - 1 year ago 176
Android Question

Disable click on chart

I am using multiple mpandroidchart in a scrollview with a linearlayout.

The thing is is i want to disable any kind of horizontal/verical scrolling in the charts because that causes problem when i'm scrolling down to next chart. I've tried setting the clickable attribute to false but that doesn't help. Is there any method in the library to disable any kind of touch event on chart? I would like it to be fully static.

Answer Source

Use the OnChartGestureListener from library : OnChartGestureListener.

Enabling / disabling interaction

  • setTouchEnabled(boolean enabled): Allows to enable/disable all possible touch-interactions with the chart.
  • setDragEnabled(boolean enabled): Enables/disables dragging (panning) for the chart.
  • setScaleEnabled(boolean enabled): Enables/disables scaling for the chart on both axes.
  • setScaleXEnabled(boolean enabled): Enables/disables scaling on the x-axis.
  • setScaleYEnabled(boolean enabled): Enables/disables scaling on the y-axis.
  • setPinchZoom(boolean enabled): If set to true, pinch-zooming is enabled. If disabled, x- and y-axis can be zoomed separately.

and many more...

Please check this answer Disable OnClickListener while scaling or dragging a View.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download