0

I have a tab based application which has only one activity. I would like to apply the android material transition effects when moving from one fragment to other. I have followed this samples. Here is what I am doing,

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_contact, container, false);
        ButterKnife.bind(this,view);
        setupWindowAnimations();
        return view;
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    private void setupWindowAnimations() {
        Fade fade = new Fade();
        fade.setDuration(1000);
        getActivity().getWindow().setEnterTransition(fade);

        Slide slide = new Slide();
        slide.setDuration(1000);
        getActivity().getWindow().setReturnTransition(slide);
    }

But this has no effect when I enter and exit the fragment which has this code added.

In my styles(V21).xml I have this added

<style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowActivityTransitions">true</item>
        <item name="android:windowContentTransitions">true</item>
    </style>

How to make this work?

Zach
  • 9,989
  • 19
  • 70
  • 107

0 Answers0