全屏的主题为AppCompat [英] Full Screen Theme for AppCompat

查看:775
本文介绍了全屏的主题为AppCompat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我怎么可以申请全屏幕主题(没有标题栏+没有动作条)到活动中。我使用AppCompat库从支持包V7。

我试图施加安卓主题=@安卓风格/ Theme.NoTitleBar.Fullscreen来我的具体活动,但它坠毁。我想这是因为我的应用程序的主题是这样的。

 <样式名称=AppTheme父=Theme.AppCompat.Light.DarkActionBar>
 

我也试过这种

  getWindow()。setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
 

这只是隐藏标题栏,但不行动起来吧。 我当前的解决方法是,隐藏的动作条

  getSupportActionBar()隐藏()。
 

解决方案

当你在你的应用程序中使用Theme.AppCompat你可以使用FullScreenTheme通过添加code下面的风格。

 <样式名称=Theme.AppCompat.Light.NoActionBar.FullScreen父=@风格/ Theme.AppCompat.Light>
    <项目名称=windowNoTitle>真< /项目>
    <项目名称=windowActionBar>假< /项目>
    <项目名称=机器人:windowFullscreen>真< /项目>
    <项目名称=机器人:windowContentOverlay> @空< /项目>
< /风格>
 

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.

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">

I also have tried this

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();

解决方案

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">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

这篇关于全屏的主题为AppCompat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆