制作一个Android应用程序全屏科尔多瓦 [英] Making an Android app fullscreen with Cordova

查看:119
本文介绍了制作一个Android应用程序全屏科尔多瓦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初来乍到科尔多瓦,并想使该全屏显示(隐藏任务栏上的Andr​​oid底部)的应用程序。

I'm a newcomer to Cordova, and am trying to make an app that appears full screen (hiding the taskbar at the bottom of Android).

我在网上看了看,似乎有两种不同的方法....我曾尝试添加

I have looked online and there seem to be two different techniques.... I have tried adding

我的config.xml

to my config.xml

,以便它读取

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <preference name="loglevel" value="DEBUG" />
    <preference name="AndroidLaunchMode" value="singleTop" />
    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
    </feature>
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <preference name="Fullscreen" value="true" />
    <preference name="WebViewBounce" value="true" />
    <preference name="Orientation" value="landscape" />
    <preference name="HideKeyboardFormAccessoryBar" value="true" />
</widget>

状态栏仍然在底部(尽管应用程序不会在景观修复)。我也曾尝试包括添加线hellocordova.java其他建议。这种进口android.view.WindowManager;然后加载index.html的后面添加行:

The status bar still remains at the bottom (although the app does fix at landscape). I have also tried the other advice which involves adding lines to hellocordova.java. This imports android.view.WindowManager; and then adds lines after loading index.html:

(WindowManager.LayoutParams.FLAG_FULLSCREEN,                   WindowManager.LayoutParams.FLAG_FULLSCREEN WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

该方法从与科尔多瓦构建Android编译停止的应用程序。

This method stops the app from compiling with cordova build android.

我在哪里可以寻找的任何提示。

Any tips of where I can be looking.

我使用的是Android 4.1.1

I'm using Android 4.1.1

推荐答案

不幸的是,插件并没有为我工作,所以我这些步骤管理它:

Unfortunately the Plugin didn't work for me, so I managed it with these steps:

添加了全屏preference在的config.xml 文件:

Add the Fullscreen preference in your config.xml file:

<preference name="Fullscreen" value="true" />

找到的Andr​​oidManifest.xml 平台/安卓/ 并添加全屏主题

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

最后,这是很难的步骤,使用href="https://developer.android.com/training/system-ui/immersive.html" rel="nofollow">沉浸式全屏模式的。我得到它的工作的唯一方法是直接延伸 plattforms /安卓/ src目录/ COM /例子 CordovaApp.java 文件/你好/

Finally, and this was the harder step, use the Immersive Full-Screen Mode. The only way I got it to work was directly extending the CordovaApp.java file in plattforms/android/src/com/example/hello/

...
import android.view.View;

//Cordova onCreate function....
//public void onCreate()
//...    

//this is the important thing:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
  super.onWindowFocusChanged(hasFocus);
  View decorView = getWindow().getDecorView();
  if(hasFocus) {
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }
}

我不是一个Java开发人员(喷),所以我不能详细发生了什么解释,但似乎工作。请记住,科尔多瓦创建平台/ Android版文件夹中,因此它可能会通过一些行动被覆盖。

I am not an Java Developer (jet) so I can't explain in detail what happend, but it seems to work. Keep in mind that Cordova creates the platforms/android folder, so its possible that it will be overwritten by some actions.

这篇关于制作一个Android应用程序全屏科尔多瓦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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