Excluding ActionBar from MaterialContainerTransform transition

Viewed 245

I am developing an Android app with the new UI transitions like the MaterialContainerTransform transition.

Specifically, I am using it in fragment transactions to animate when new fragments are shown to the user.

My problem is that I do not change the action bar, but during the transition the action bar and status bar still get darker, like the rest of the old fragment, which looks weird to the user because these parts of the UI never change.

I've tried using excludeTarget() on the MaterialContainerTransform but unfortunately, it has no effect.

This is my current code in my destination fragment's onCreate().

MaterialContainerTransform materialContainerTransform = new MaterialContainerTransform();

// this has no effect
materialContainerTransform.excludeTarget(R.id.toolbar, true);
materialContainerTransform.excludeTarget(android.R.id.statusBarBackground, true);
materialContainerTransform.excludeTarget(android.R.id.navigationBarBackground, true);

this.setSharedElementEnterTransition(materialContainerTransform);

Is there any way to exclude the action and status bars so that the user does not see a weird flickering?

1 Answers

Setting the scrimColor to transparent seems to stop the flickering.

materialContainerTransform.setScrimColor(Color.TRANSPARENT)
Related