问题
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