AppCompat 的全屏主题 [英] Full Screen Theme for AppCompat
问题描述
我想知道如何将全屏主题(无标题栏 + 无操作栏)应用于活动.我正在使用支持包 v7 中的 AppCompat 库.
I would like to know how can I apply full screen theme ( no title bar + no actionbar ) to an activity. I am using AppCompat library from support package v7.
我尝试将 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
应用于我的特定活动,但它崩溃了.我想是因为我的应用主题是这样的.
I've tried to applied android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
to my specific activity but it crashed. I think it's because my application theme is like this.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
我也试过这个
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
只隐藏标题栏而不隐藏操作栏.我目前的解决方法是用
which only hides title bar but not the action bar. My current workaround is that hiding the actionbar with
getSupportActionBar().hide();
推荐答案
当您在应用程序中使用 Theme.AppCompat 时,您可以通过将以下代码添加到样式中来使用 FullScreenTheme.
When you use Theme.AppCompat in your application you can use FullScreenTheme by adding the code below to styles.
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
并在您的清单文件中提及.
and also mention in your manifest file.
<activity
android:name=".activities.FullViewActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
/>
这篇关于AppCompat 的全屏主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!