android:theme="@android:style/Theme.NoTitleBar.Fullscreen"适用于应用程序级别,但不适用于活动级别.有什么线索吗? [英] android:theme="@android:style/Theme.NoTitleBar.Fullscreen" works on Application level but not at the activity level. Any clue?

查看:25
本文介绍了android:theme="@android:style/Theme.NoTitleBar.Fullscreen"适用于应用程序级别,但不适用于活动级别.有什么线索吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个名为 MyNoStatusBarActivity.java 的活动设为全屏活动.

I need to make one of my activities called MyNoStatusBarActivity.java a full-screen activity.

我已在清单中添加:

<activity
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:name=".MyNoStatusBarActivity"
    android:noHistory="true"
    android:label="@string/app_name"
    android:configChanges="touchscreen|keyboard|keyboardHidden|navigation|orientation">
    ...
</activity>

并且在我的活动的 onCreate 中:

And in the onCreate of my activity :

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

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

这样做只会隐藏 TITLE 栏而不是 STATUS 栏.

Doing all this just hides the TITLE bar and not the STATUS bar.

此外,如果我在应用程序级别使用清单主题而不是我的活动,它可以工作,但适用于我的应用程序的所有活动,这不是我想要的.我只想要一项特定活动的无状态栏.

Also if I use the manifest theme on the application level instead of my activity, it works but for all activities of my app which is not what I want. I want the no status bar only for one particular activity.

非常感谢您的帮助.谢谢!

Help will be really appreciated. Thnx!

P.S :我觉得这个行为在 Honeycomb/ICS 中不再可用.我只需要 2.2 和 2.3

P.S : I am ok is this behavior is no longer available in Honeycomb/ICS. I need this just for 2.2 and 2.3

编辑

尝试了 SO 中其他解决方案中提到的所有建议,但尚未成功.主题应用于应用程序级别时有效,但不适用于活动级别.

Tried all the suggestions mentioned in other solutions in SO but no success yet. Theme works when applied to the application level but not on the activity level.

我使用的是 HTC WildFire-S,安卓 2.3.5 版

I am using HTC WildFire-S, android ver 2.3.5

推荐答案

在您的清单 xml 中,在应用程序级别放置:

In your manifest xml, at application level put this:

<application
    ...
    android:theme="@android:style/Theme.NoTitleBar" >
</application>

并在您想要全屏显示的活动中输入:

and in the activity that you want to make full screen put this:

<activity

     android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
     ...
</activity>

删除 onCreate 中的所有 setWindowsFeature 或 setFlag 方法.

Remove all the setWindowsFeature or setFlag methods in onCreate.

这篇关于android:theme="@android:style/Theme.NoTitleBar.Fullscreen"适用于应用程序级别,但不适用于活动级别.有什么线索吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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