我無法實現之間的兩個片段的過渡,所以我最終改變目標片段活動,用下面的代碼的活動
View imageView = findViewById(R.id.imageView);
View textView = findViewById(R.id.textView);
View button = findViewById(R.id.button);
Intent intent = new Intent(this, EndActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
textView.setTransitionName(getString(R.string.activity_text_trans));
button.setTransitionName(getString(R.string.activity_mixed_trans));
Pair<View, String> pair1 = Pair.create(imageView, imageView.getTransitionName());
Pair<View, String> pair2 = Pair.create(textView, textView.getTransitionName());
Pair<View, String> pair3 = Pair.create(button, button.getTransitionName());
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(this, pair1, pair2, pair3);
startActivity(intent, options.toBundle());
}
else {
startActivity(intent);
}
}
變化的android:持續時間=「700」in slide_in_left.xml –
查看https://stackoverflow.com/a/26984314/3496570 – Nepster
@mohitSuthar我在slide_in_left.xml中添加了持續時間,但dint工作 – Vijay