How to exit fullscreen (show Action Bar) programmatically on Android 4.0+?

喜你入骨 提交于 2019-12-10 23:41:44

问题


If I have an Activity with a fullscreen theme, set up like this:

<activity
    android:name=".FullscreenActivity"
    android:theme="@style/MyTheme.FullScreen"/>

With MyTheme.FullScreen defined as:

<style name="MyTheme.FullScreen" 
       parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
</style>

... is it possible to exit fullscreen mode programmatically? I specifically want to show the Action Bar (with its navigation options) in certain situations, while usually having the activity in fullscreen mode.

I have tried approaches like the following as suggested here. From some comments, others are having problems with this on Android 4.0+ too.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
currentContentView.requestLayout();

Also tried content.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);, to no avail.

I also looked at "Smooth full screen transition", but it seems a bit hacky for my needs, and I'd much prefer a simpler solution.

Targeting Android 4.0 and above:

android:minSdkVersion="14"
android:targetSdkVersion="19"

来源:https://stackoverflow.com/questions/21363224/how-to-exit-fullscreen-show-action-bar-programmatically-on-android-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!