隐藏Sencha Touch 2应用程序上的Android通知栏



我已经成功地将我的应用程序编译成apk文件,并部署到我的Android设备上。

但是当我在那里运行它时,通知栏存在,我希望它是全屏的,没有通知栏。

这是屏幕顶部的栏,带有电池使用情况,wifi/3G连接,新的电子邮件图标等。

我们如何在使用Sencha Touch 2将其隐藏在编译的应用程序中?

我已经在加载的第一个视图(登录屏幕)的配置中设置了全屏:true,并且还设置了:

Ext.application({
   viewport: {
      autoMaximize: true
   }
});

您可以在AndroidManifest.xml中更改此设置:

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

您实际上可以在 SenchaCmd 中修改 AndroidManifest.xml 模板来获取此模板,如 Sencha 论坛中所述。

该文件将以 Sencha/Cmd/<CmdVersion>/stbuild/st-res/android/AndroidManifest.xml .您需要在 application 标记上设置主题属性,如下所示:android:theme="@android:style/Theme.NoTitleBar"

整个标签如下所示:

<application android:icon="@drawable/icon" android:label="%s" android:theme="@android:style/Theme.NoTitleBar">

但是,这个解决方案仍然非常糟糕,我很想看到一些无需修补 Sencha 代码即可工作的东西。

只需添加此内容即可在super.onCreate(savedInstanceState);之前使屏幕全屏this.setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);

添加this.requestWindowFeature(Window.FEATURE_NO_TITLE);this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN) setContentView

例如:

@Override
public void onCreate(Bundle savedInstanceState){
/**sets Theme and Style (must be set BEFORE super.onCreate)*/
this.setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
/**Changes Window. Removes title and/or notification bar (must be set BEFORE setContentView)*/
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);

(或者你可以按照homer_simpson所说的通过清单来做到这一点。

最新更新