Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate view from bottom to top in android

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

like image 290
user1537457 Avatar asked Jan 13 '13 08:01

user1537457


People also ask

How do I animate a view in Android?

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.

Is animation possible on Android?

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.

What is transition animation in Android?

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.


1 Answers

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);
}
like image 101
pvllnspk Avatar answered Nov 14 '22 06:11

pvllnspk