Reputation: 2053
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowSharedElementsUseOverlay">false</item>
</style>
or excluding from java class navigation and statusbar from transition
View decor = ((PhotosActivity)context).getWindow().getDecorView();
View statusBar = decor.findViewById(android.R.id.statusBarBackground);
View navBar = decor.findViewById(android.R.id.navigationBarBackground);
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation((PhotosActivity) context,
new android.support.v4.util.Pair<>(photo, "photo")
new android.support.v4.util.Pair<>(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME),
new android.support.v4.util.Pair<>(navBar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
);
context.startActivity(photoIntent, options.toBundle());
it continues blinking
Upvotes: 7
Views: 2800
Reputation: 325
View decor = getWindow().getDecorView();
this decor
view used to get the default action bar.
makeSceneTransitionAnimation
used to define the shared widgets between the two activities.
To prevent flickering for action bar, status bar and navigation bar. Please add these lines of code in the onCreate
method for the 2 Activities:
Fade fade = new Fade();
View decor = getWindow().getDecorView();
fade.excludeTarget(decor.findViewById(R.id.action_bar_container), true);
fade.excludeTarget(android.R.id.statusBarBackground, true);
fade.excludeTarget(android.R.id.navigationBarBackground, true);
getWindow().setEnterTransition(fade);
getWindow().setExitTransition(fade);
Upvotes: 4