0

Customer request:

I want to create smooth transition between all activity by moving 2 png elements of my background (customer request). In detail: I have a right element that should move to the left for 20sp, and a miror element on the left that should move on the right.

My current code:

The transition looks good, for this I have created 2 shared elements with the same "transitionName" in all my activity layout:

android:transitionName="transitionLeft"

In my manifest I have set my own style:

    <application
    android:allowBackup="true"
    android:fullBackupContent="@xml/backup_descriptor"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

In my "res/values/style.xml" I have set windowsContentTransitions to true:

<!-- Activity theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
</style>

And, to be sure, in all my activity at the beginning of onCreate() I have added:

getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);

In all activity on onWindowFocusChanged() I set SYSTEM_UI_FLAG_FULLSCREEN:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    // Hide the nav bar and status bar
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN);
        
    }
}

My problem:

When I open an activity, the transition already run, but I always seen a brief fade on tool and title bar and I don't want to have it. But, in my opinion, I made all to already hide those bars but it won't works fine.

1 Answers1

0

I find the fix: The issue is related to my application that is in fullscreen. So to lock the status and nav bar you must set decorView.setSystemVisibility to SYSTEM_UI_FLAG_IMMERSIVE_STICKY at the beginning of the onCreate like:

getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN);

With this I never see nav and status bar again