I have an activity which includes a viewpager with 3 fragments. From the first tab, I am calling another activty and trying to exclude toolbar and tab bar from the exit transition.
if (Build.VERSION.SDK_INT >= 21) {
getActivity().getWindow().setExitTransition(new Slide(Gravity.LEFT).excludeTarget(R.id.toolbar,true));
Pair<View, String> pair1 = Pair.create((View) matCvr, matCvr.getTransitionName());
Pair<View, String> pair2 = Pair.create((View)matTxt, matTxt.getTransitionName());
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),pair1,pair2);
ActivityCompat.startActivity(getActivity(), matIntent, options.toBundle());
}
The issue is excludeTarget seems not working and the whole view is sliding to Left. I have tried addTarget like below for including viewpager alone.But in that case, the default Fade animation is happening.
getActivity().getWindow().setExitTransition(new Slide(Gravity.LEFT).addTarget(R.id.viewPager));
Has anyone faced this issue? Any help appreciated.
The issue appears when I have the views inside
android.support.v4.widget.DrawerLayout / android.support.design.widget.AppBarLayout
We need to make android:transitionGroup="false" explicitly for the parent views.