Q:

Android : Start a transition after another one ends

I have a transition applied to several buttons where I try to change their width from 0dp to MATCH_PARENT
final ChangeBounds transition = new ChangeBounds();
startFloat.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        for(i=0;i<allCards.size();i++) {
            if(i%2 == 0) {
                transition.setDuration(4000L);
                TransitionManager.beginDelayedTransition(allCards.get(i), transition);
                allButton.get(i).setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp10));
            }
            else{
                transition.setDuration(400L);
                TransitionManager.beginDelayedTransition(allCards.get(i), transition);
                allButton.get(i).setLayoutParams(new MaterialCardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp10));
            }
        }
    }
});

Note: dp10 is an integer variable (No problem there).
This seems to work fine, however, when I click startFloat button, all the transitions occur at the same time. I want them to start after the previous one ends.
Any idea of how to achieve the same?

A:

I was able to solve my problem by using transition.setStartDelay(delay).
Here is my code:
final ChangeBounds transition = new ChangeBounds();
startFloat.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        for(int i=0;i<allCards.size();i++) {
            if(i%2 == 0) {
                transition.setDuration(4000L);
                transition.setStartDelay(delay);
                TransitionManager.beginDelayedTransition(allCards.get(i), transition);
                allButton.get(i).setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp10));
                delay+=4000;
            }
            else{
                transition.setDuration(400L);
                transition.setStartDelay(delay);
                TransitionManager.beginDelayedTransition(allCards.get(i), transition);
                allButton.get(i).setLayoutParams(new MaterialCardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp10));
                delay+=400;
            }
        }
    }
});

