我做了一些測試,但不幸的是我也無法使它工作。它看起來像setStartDelay
只適用於ChangeBounds
過渡。
請看下面的例子(當您將在first
過渡startDelay
,延遲將無法正常工作):
linearLayout = (LinearLayout) findViewById(R.id.testLinearLayout);
mSceneRoot = (ViewGroup) findViewById(R.id.rootView);
mStaggeredTransition = new TransitionSet();
Transition first = new Fade(Fade.OUT);
Transition second = new ChangeBounds();
Transition third = new Fade(Fade.IN);
second.setStartDelay(1000).addTarget(linearLayout);
mStaggeredTransition.setOrdering(ORDERING_SEQUENTIAL);
mStaggeredTransition.addTransition(first).addTransition(second).addTransition(third);
findViewById(R.id.testbutton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
linearLayout.setVisibility(View.GONE);
TransitionManager.beginDelayedTransition(mSceneRoot, mStaggeredTransition);
linearLayout.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout.getLayoutParams();
params.addRule(ALIGN_PARENT_END);
linearLayout.setLayoutParams(params);
}
});
所以我建議你使用這樣的:
mSceneRoot.postDelayed(new Runnable() {
@Override
public void run() {
TransitionManager.beginDelayedTransition(rootViewGroup, new AutoTransition().setStartDelay(1000));
linearLayout.setVisibility(View.VISIBLE);
}
}, 1000);
打開了一個機票https://issuetracker.google.com/issues/64139005 –