Exit transition in translucent activity

2653 views android
2

I'm trying to do a simple fade out transition when a translucent activity. The style of the activity is:

<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>

Fade in enter transition works smoothly but fade out exit transition after calling finishAfterTransition() just blinks between my current (translucent) activity and the previous one.

I got it working performing a regular animation on the layout and then finishing the activity. But I would really like to know how to do it with the Transition Framework on activities.

answered question

1 Answer

7

You can implement fade-in and fade-out animation by this way also.     
 Create anim folder under res folder, In anim folder create two xml file.
     -------------------------------------------------------------------------------------
     fadein.xml

     <?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />
     -------------------------------------------------------------------------------------

       fadeout.xml

       <?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0" android:
    duration="2000" />

     -------------------------------------------------------------------------------------
     Add this on override method of onCreate and onStart.

     overridePendingTransition(R.anim.fadein, R.anim.fadeout);


     @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            overridePendingTransition(R.anim.fadein, R.anim.fadeout);

            }


     @Override
        protected void onStart() {

            super.onStart();

            overridePendingTransition(R.anim.fadein, R.anim.fadeout);
           }

posted this

Have an answer?

JD

Please login first before posting an answer.