我是Cordova的新手,我正在尝试制作一个全屏显示的应用程序(将任务栏隐藏在Android的底部).
我看过网上似乎有两种不同的技术....我试过添加
<preference name="Fullscreen" value="true" /> to my config.xml
Run Code Online (Sandbox Code Playgroud)
所以它读
<?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>
Run Code Online (Sandbox Code Playgroud)
状态栏仍然位于底部(尽管应用程序确实在横向上修复).我还尝试了其他建议,包括在hellocordova.java中添加行.这导入android.view.WindowManager; 然后在加载index.html后添加行:
(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
此方法停止使用cordova build android编译应用程序.
我可以看到的任何提示.
我正在使用Android 4.1.1
不幸的是插件不适合我,所以我通过以下步骤管理它:
在config.xml文件中添加全屏首选项:
<preference name="Fullscreen" value="true" />
Run Code Online (Sandbox Code Playgroud)
查找AndroidManifest.xml中platforms/android/,并添加全屏主题
<manifest ...>
<application ...>
<activity ... android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
Run Code Online (Sandbox Code Playgroud)
最后,这是更难的步骤,使用沉浸式全屏模式.我让它工作的唯一方法是直接扩展CordovaApp.java文件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);
}
}
Run Code Online (Sandbox Code Playgroud)
我不是Java开发人员(jet)所以我无法详细解释发生了什么,但似乎有效.请记住,Cordova会创建该platforms/android文件夹,因此可能会被某些操作覆盖.
Android上的底栏称为导航栏,您正在寻找的模式称为沉浸式模式.这些条款可以帮助您进行未来的网络搜索.尝试使用此插件 https://github.com/mesmotronic/cordova-fullscreen-plugin
| 归档时间: |
|
| 查看次数: |
20216 次 |
| 最近记录: |