requestWindowFeature(Window.FEATURE_NO_TITLE); not working in Froyo and Gingerbread

一个人想着一个人 提交于 2019-12-25 02:25:49

问题


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.

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

回答1:


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

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

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.

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.

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

hope that it helps.



来源:https://stackoverflow.com/questions/25164171/requestwindowfeaturewindow-feature-no-title-not-working-in-froyo-and-gingerbr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!