Reputation: 494
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
}
}
}
Upvotes: 3
Views: 2309
Reputation: 477
graph.animateY(1000, Easing.EasingOption.Linear);
Linear replace with anyone of the following
Linear, EaseInQuad, EaseOutQuad, EaseInOutQuad, EaseInCubic, EaseOutCubic, EaseInOutCubic, EaseInQuart, EaseOutQuart, EaseInOutQuart, EaseInSine, EaseOutSine, EaseInOutSine, EaseInExpo, EaseOutExpo, EaseInOutExpo, EaseInCirc, EaseOutCirc, EaseInOutCirc, EaseInElastic, EaseOutElastic, EaseInOutElastic, EaseInBack, EaseOutBack, EaseInOutBack, EaseInBounce, EaseOutBounce, EaseInOutBounce,
Upvotes: 2
Reputation: 776
Did you try setting mBarChart.animateY(2000);
in onCreate()
? That should animate it once and not again on swipe. I have not tried it but give it a try.
Upvotes: 0