Android immersion transitions
I have an Android app that uses immersive mode for all activities - so this is a fully functional full screen app.
I have a BaseActivity class from which all other activities are propagated. In this operation, I call the following to enable fullscreen / immersive
HelmiBlankActivity:
private boolean apiLowerImmersive = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
apiLowerImmersive = true;
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus && !apiLowerImmersive ) {
getWindow().getDecorView().setSystemUiVisibility(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
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
}
In actions it works great, the problem is this: when opening a new action (by design) the action bar / title is displayed for a short time and then hidden again - which seems like a laggy / buggy.
The app also has a theme: styles.xml:
<style name="FullscreenTheme" parent="android:Theme.Holo.Light">
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
I tried to apply android: Theme.Holo.Light.NoActionBar and also - failed during transitions. I couldn't find anything on stackoverflow (which is a great community by the way and helped me with a lot of problems) or anywhere else on the Internet, and would appreciate your help.
source to share
If you put this snippet in the onCreate () method, your actions will open with bars already hidden.
getWindow().getDecorView().setSystemUiVisibility(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
| View.SYSTEM_UI_FLAG_IMMERSIVE);
You can also add conditions for older SDKs. The only problem I have with this setup is the fact that when I scroll down to show the bars, they will no longer be hidden ...
source to share