I used header for my listview. this header should be shown at the certain time on top of the listview.
I tried this piece of code: listview.addHeaderView(header,null,true);
it works well, now I want to set an animation for this header, for example the header appears from right to left or something like that, how to do this? I can not find any helpful code.
thanks.
Asked
Active
Viewed 1,529 times
0

user3427977
- 115
- 1
- 1
- 8
1 Answers
0
Did you try, after you added the header view to your listview, to run a basic animation such as :
Animation animationStart = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left);
animationStart.setDuration(2000);
headerView.startAnimation(animationStart);
if this does not wok it might be because the view is not displayed yet. In this case i would like to know if you have a custome adapter for your listView or if you use a default one :) ?

JkSuf
- 343
- 1
- 6
- 22
-
thank you, i thought I should add animation to header before adding header to listview – user3427977 Sep 16 '14 at 16:16
-
I don't really understand what you mean by "but it does not work for removeHeader" ^^". Do you want an animation when you remove the header too ? – JkSuf Sep 17 '14 at 07:20
-
yes I do, but if i set animation after removing it removes without any animation – user3427977 Sep 17 '14 at 09:12
-
Yes this is normal, because you remove the view and the set the animation. I thought that you would have an exception (as your view has been removed from layout) but i guess that the view (i mean je that object) still exists in memory, so this is why you don't have exception. To implement the behaviour you want, you must start an animation when you want to remove your view, and add a listener to the animation so that, when the animation is finished, you remove the view. Here is a usefull link : http://stackoverflow.com/questions/3025163/how-to-remove-a-view-when-animation-ends – JkSuf Sep 17 '14 at 09:17