I have listView in which i am adding item from bottom. I want to animate added item and rest of list view should slide up. Animation effect should be from bottom to top. I have tried translate animation but it slides only added item. Thanks
You can use the view animation system to perform tweened animation on Views. Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation.
On Android 4.4 (API level 19) and higher, you can use the transition framework to create animations when you swap the layout within the current activity or fragment. All you need to do is specify the starting and ending layout, and what type of animation you want to use.
Animation by Transition is an object (View) properties change based on object location on display and set effect. Since Transition has appeared in Android (4.4 KitKat version) there's a conception of Scene, and the changing between scenes is called Transition.
public static void slideToBottom(View view){
TranslateAnimation animate = new TranslateAnimation(0,0,0,view.getHeight());
animate.setDuration(500);
animate.setFillAfter(true);
view.startAnimation(animate);
view.setVisibility(View.GONE);
}
public static void slideToTop(View view){
TranslateAnimation animate = new TranslateAnimation(0,0,view.getHeight(),0);
animate.setDuration(500);
animate.setFillAfter(true);
view.startAnimation(animate);
view.setVisibility(View.VISIBLE);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With