【Android】Fragment Lolipop以降

Activity

    FragmentManager fragmentManager = getFragmentManager();

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    LoginFragment login_fragment = new LoginFragment();

   

    fragmentTransaction.setCustomAnimations(

        R.animator.fadein,

        R.animator.fadeout

        );

   

    fragmentTransaction.replace(android.R.id.content, login_fragment);

    fragmentTransaction.commit();

 

animaotr/fadein.xml

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"

    android:interpolator="@android:interpolator/linear"

    android:valueFrom="0"

    android:valueTo="1"

    android:propertyName="alpha"

    android:duration="200" />

Leave a Reply