Here's the situation:
I have a LinearLayout
containing vertically n CardView
.
I want to customise the way it's rendered by adding animation on cards.
When the layout is rendered (maybe in onResume()) i want each card to slide from the bottom to the position the card should have taken if not animated, like in the illustration above:
The yellow arrow represent the
LinearLayout
's paddingTop and the purple arrow represents the CardView
's marginBottom.
I don't know how to achieve this because i can't get the final position, that's why i came here to ask you if someone has already done this or similar.
I tried to use LayoutTransition
with ObjectAnimator
added to the LinearLayout
that animate children when added/removed, but i have to pass a view (the child, that i'm not suppose to know at this time) in ObjectAnimator
's constructor..
I also tried this:
[...]
int deviceHeight = getResources().getDisplayMetrics().heightPixels;
[...]
@override
public onResume() {
super.onResume();
card.animate().y(position)
.withStartAction(new Runnable(){
@Override
public void run(){
card.setY(deviceHeight);
}
});
but i can't get the value of position (i always get 0) or if i change it to .y(-deviceHeight) the card is rendered at his position then moved to bottom before it slides to the top of LinearLayout
but the paddingTop is not even considered..
EDIT: To sum up, i want to make something similar to what happens when android:animateLayoutChanges="true" is set and you remove the first child: the other children just slide up to fill the place remained empty (except that i want to add some delay between each child animation)