Has anybody else noticed the white screen that a Slide window transition creates when it starts?

I would like to remove this if possible. I am using an activity with a black background, that same activity has a toolbar and a DrawerLayout as well. This white screen makes the look inconsistent.

Sadly, there is very little information about this so I haven’t found a solution to it yet. It can become a lot more apparent when you set a very slow duration to the Slide transition when opening an activity.

  • Google Play security alert for insecure TrustManager
  • Where exactly in the Android OS is text renderred?
  • MVC pattern on Android
  • How to share a single library source across multiple projects
  • Get only email address from contact list Android
  • How to upload images in gallery of android emulator
  • Is there any way to remove this?

    Code that sets the enter transition on the second activity :

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = activity.getWindow();
    
            Slide slide = new Slide();
            slide.setSlideEdge(Gravity.RIGHT);
            slide.excludeTarget(android.R.id.statusBarBackground, true);
            slide.excludeTarget(android.R.id.navigationBarBackground, true);
            window.setEnterTransition(slide);
            window.setExitTransition(slide);
        }
    

    My styles

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowActivityTransitions">true</item>
        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">false</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowSoftInputMode">stateAlwaysHidden|adjustResize</item>
    </style>
    

    Related posts:

    Why use Service for background tasks?
    How to draw a pie chart in android
    Apache Commons NET: Should I create a new FTPClient object on each connection or reuse one?
    Android Layout: width half of parent
    How slow or fast is Qt mobile for android
    Unable to compile my android project
  • Android : App support for multiple tablet screen resolutions
  • Android ADB: Simulate Recent App key press
  • Using Espresso to click view inside RecyclerView item
  • Downloaded files not appearing in the Downloads App in android
  • How to create transparent activity in android?
  • Menu Items are not showing on Action Bar
  • 2 Solutions collect form web for “Has anybody else noticed the white screen that a Slide window transition creates when it starts?”

    How to fix the white screen during the slide in transition for the started activity:

    karaokyos answer utilizes the pre Lollipop
    activity transitions. These transitions target the whole activity screen and don’t provide capabilities to exclude parts of the screen during the transition.

    John Ernest Guadalupe approach utilizes the transitions introduced in Lollipop (Activity & Fragment Transitions). The observed “white screen” is the window background, that is fading in during the transition (more info about Activity & Fragment Transitions ). I guess you are setting the “black background” of your activities in the root view of your layout? Setting the window background to black should solve your problem.

    Programmatically:

    window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    

    Theme:

    <item name="android:windowBackground">@android:color/black</item>
    

    This is the resulting transition.

    Resulting Transition

    Edit: How to provide the required slide out (left) transition for the calling activity

    First Activity:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        Slide slide = new Slide();
        slide.setInterpolator(new LinearInterpolator());
        slide.setSlideEdge(Gravity.LEFT);
        slide.excludeTarget(android.R.id.statusBarBackground, true);
        slide.excludeTarget(android.R.id.navigationBarBackground, true);
        window.setExitTransition(slide); // The Transition to use to move Views out of the scene when calling a new Activity.
        window.setReenterTransition(slide); // The Transition to use to move Views into the scene when reentering from a previously-started Activity.
        window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    }
    

    Second Activity:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        Slide slide = new Slide();
        slide.setInterpolator(new LinearInterpolator());
        slide.setSlideEdge(Gravity.RIGHT);
        slide.excludeTarget(android.R.id.statusBarBackground, true);
        slide.excludeTarget(android.R.id.navigationBarBackground, true);
        window.setEnterTransition(slide); // The Transition to use to move Views into the initial Scene.
        window.setReturnTransition(slide); // The Transition to use to move Views out of the Scene when the Window is preparing to close.
        window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    }
    

    You can try different interpolators to change the pace of the transition.

    Resulting transition with LinearInterpolator:

    Resulting transition

    If you want to get rid of the gap between the slide out of the first and slide in of the second activity you can set:

    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    

    How to debug transitions:

    It can become a lot more apparent when you set a very slow duration to the Slide transition when opening an activity.

    To (visually) debug transitions there are 3 options (“Window animation scale”,”Transition animation scale”, “Animation duration scale”) in the development settings to multiply the duration of all transitions/animations.

    Seems like the old activity will not “stay” in view when you have a custom transition. I don’t know when that started, but you definitely didn’t need a stay animation in some previous API levels. The old 2.0 era overridePendingTransition still works fine:

    anim/slide_in.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:fromXDelta="100%"
            android:toXDelta="0%"
            android:duration="600"
            />
    </set>
    

    anim/slide_out.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:fromXDelta="0%"
            android:toXDelta="100%"
            android:duration="600"
            />
    </set>
    

    anim/stay.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate android:duration="600"/>
    </set>
    

    Main activity’s startActivity:

    startActivity(intent);
    overridePendingTransition(
            R.anim.slide_in,
            R.anim.stay
    );
    

    Second activity’s return:

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    
        overridePendingTransition(
                0,
                R.anim.slide_out
        );
    }
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.