Reputation: 383
I am using layout transition, to trigger some animations when i set views to View.GONE and View.VISIBLE.
it is working, there are 4 flags i am using to tell it what view to animate and when. these are:
LayoutTransition.APPEARING-animate the view that is set to visible. LayoutTransition.CHANGE_APPEARING-when view is set to visible, animate other views in group. LayoutTransition.DISAPPEARING-animate the view that is set to gone. LayoutTransition.CHANGE_DISAPPEARING-when view is set to gone, animate other views in group.
this is the code where i set the animations
transition.setAnimator(LayoutTransition.APPEARING, changeOut2);
transition.setAnimator(LayoutTransition.CHANGE_APPEARING, changeOut2);
transition.setAnimator(LayoutTransition.DISAPPEARING, changeOut1);
transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changeOut1);
my issue is that the change flags are not running the animations, but the others are working fine.
EDIT: added listener
Layout: There are three cardviews all in the same linear layout which has the LayoutTransition set to it. two are disappearing and the change_disappearing should run for the third cardview that remains in view.
i have added a listener as follows:
transition.addTransitionListener(new LayoutTransition.TransitionListener(){
@Override
public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
switch(transitionType){
case LayoutTransition.APPEARING:
Log.i("anim", "APPEARING: "+view.toString());
break;
case LayoutTransition.DISAPPEARING:
Log.i("anim", "DISAPPEARING: "+view.toString());
break;
case LayoutTransition.CHANGE_APPEARING:
Log.i("anim", "CHANGE_APPEARING: "+view.toString());
break;
case LayoutTransition.CHANGE_DISAPPEARING:
Log.i("anim", "CHANGE_DISAPPEARING: "+view.toString());
break;
}
}
@Override
public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
}
});
I am getting correct logs for APPEARING and DISAPPEARING, but no logs from either of the CHANGE flags, although i did get change logs initially for the parent so i set the following:
transition.setAnimateParentHierarchy(false);
logs currently look like:
11-20 16:04:05.195 13612-13612//*PACKAGE*/ I/anim﹕ APPEARING: android.support.v7.widget.CardView{4289d238 V.E...C. ......ID 0,0-1080,512 #7f080057 app:id/home_card}
11-20 16:04:05.195 13612-13612//*PACKAGE*/ I/anim﹕ APPEARING: android.support.v7.widget.CardView{428a3e80 V.E...C. ......ID 0,512-1080,1024 #7f080059 app:id/home_card1}
Upvotes: 1
Views: 1316