(This topic is not about .setfillafter(true)).
I got a little trouble with the animations of android and i hope someone can help me with this one.
I created a Linearlayout and a listview.
The listView is placed in a relative layout because i had to set the translationY of an other linearLayout in the same relative layout but i keep that other linearlayout excluded from the question.
When someone clicks or taps on the linearlayout (that will act like a button) the listview will animate a little bit downwards with the following lines:
animation_Fold = new TranslateAnimation(0, 0, 0, 150);
createNewAnimationListener(); //to monitor when the animation ends and starts.
animation_Fold.setDuration(300);
animation_Fold.setFillAfter(true);
listview_Contacts.startAnimation(animation_Fold);
As you can see i create the animation, and it will move 150(pixels?) downwards.
Now there is some more code to animate the listview back to its original position but i think this is irrelevant to this question. (it’s practically the same but then fromYDelta and toYDelta will be reversed.)
When i click on the listview (does not matter where i click) after it has been animated, it wil kick back to its original position.
But i used .setFillAfter(true), so why is this happening to me? Because i just want the listview to hold its new given position. (the position of the animation)
I hope someone can help me with this to finish my animation because i got stuck at this one.
Ok, i feel a little bit weird because you all think i talk to myself and i’d like to answer my own questions. But no, fortunately that is not the case.
So to the point.
I solved my own problem but i don’t think this is the way it’s meant to solve.
As i mentioned in a comment to
Amokrane Chentiri found out that when you disable the listview you don’t have to set a physical position.This means that when i click on the listview when the animation is done and when the listview is disabled the listview does not respond and will ignore every user input (and listeners.)
But what can i do with a listview that is disabled, Simply nothing.
But when the animation is performed once, the listview does not need to interact with the user so disabling is a good thing and one step closer to my solution.
The only thing i had to solve is enabling the listview at the right moment when the animation is reversed again.
I did this by disabling the listview and made the RelativeLayout underneath the ListView clickable with a onClickListener.
The onClickListener listens when the user clicks on the listView, sets the animation in reverse and enables the listview again. Problem Solved.
This made the listview Invisible to the userinteraction.
The onClickListener that monitors when the relativeLayout is clicked.
Feel free to answer or add comments for a better solution, otherwise i hope this solution helped other people out.