requestWindowFeature(Window.FEATURE_NO_TITLE);在Froyo和Gingerbread中不起作用 [英] requestWindowFeature(Window.FEATURE_NO_TITLE); not working in Froyo and Gingerbread

查看:81
本文介绍了requestWindowFeature(Window.FEATURE_NO_TITLE);在Froyo和Gingerbread中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全屏应用.我正在使用requestWindowFeature(Window.FEATURE_NO_TITLE)删除标题.这对于我的4.1.2智能手机和4.4.2仿真器非常有效. 在2.2模拟器,2.2智能手机和2.3.6平板电脑上,标题仍在显示.我做了很多尝试,例如在Manifest中更改样式或在styles.xml中编辑这些样式,无济于事.

I have an fullscreen apllication. I'm using requestWindowFeature(Window.FEATURE_NO_TITLE) to remove the title. This works very well for my 4.1.2 Smartphone and the 4.4.2 Emulator. In the 2.2 Emulator, on my 2.2 Smartphone and on my 2.3.6 tablet the title is still being displayed. I tried very much things like changing styles in the Manifest or editing those styles in the styles.xml, nothing works.

这是我的onCreate():

Here's my onCreate():

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


    GameData.display = new Display(this);
    setContentView(GameData.display);



    CoreData.mainActivity = this;

    NetworkData.init();
}

推荐答案

如果要删除标题,只需将此样式添加到清单文件中即可.

If you want to remove the title, just add this style into your manifest file.

android:theme="@style/Theme.Black.NoTitleBar"

然后出现问题,通知您必须使用appcompat库的派生类.这是因为您使用的是支持库v7,&在创建项目时,会创建一个活动,该活动不会作为Activity类扩展,而会作为ActionBarActivity类扩展.

then the problem arises, notifying that you must use a derivative of an appcompat library. this is because you are using the support library v7, & on creating your project, an activity creates which doesn't extends as an Activity class, but ActionBarActivity class.

因此,如果您确实要使用支持库,请创建您在值,values-v11,values-v14文件夹&下创建的主题.在主题清单上应用主题.

so, if you really want to use the support library, create the theme that you created under values, values-v11, values-v14 folders & apply your theme on your manifest.

否则,将您的ActionBarActivity类更改为Activity类&将Theme.Black.NoTitleBar主题应用于清单.

else, change your ActionBarActivity class into Activity class & apply Theme.Black.NoTitleBar theme to your manifest.

希望有帮助.

这篇关于requestWindowFeature(Window.FEATURE_NO_TITLE);在Froyo和Gingerbread中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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