MPAndroid Chart Animation to start

Viewed 1857

I am using MPAndroid Chart for the Charts in my Application. I want to animate the chart, whenever the user gets on the View of this chart.

I have two charts between which the User can swipe. The problem is now, that whenever I swipe from one View to the other, the Chart is visible for a short time and then starts animating. This behavior makes the animation look crappy.

My code for starting the animation, whenever the user gets to see the View is this. I also wrote a TODO for where i need help.

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);
    if (isVisibleToUser) {
        if (mBarChart != null) {
            mBarChart.animateY(2000);
        }
    } else {
        if(mBarChart != null) {
            // TODO: Set Back Animation so the bars will be invisible when swiping back to the view
        }
    }
}
2 Answers
Related