【问题标题】:Phonegap full screen and landscape issues?Phonegap全屏和横向问题?
【发布时间】:2015-05-07 06:17:38
【问题描述】:

我有一个使用 adobe phonegap-build 创建的 phonegap 应用程序,我有 2 个非常困难的简单问题!修复。

似乎我所做的一切,都没有多大用处。

1)在android中,我希望应用全屏(没有“home”、“return”、“multi-window”栏),全屏!

2)我希望应用程序仅是横向的,大多数情况下都是这样,但是在开始的几秒钟内(进入应用程序时),方向是纵向的,只有在几秒钟后它才会自行修复,一点都不好

这是我的 cordova config.xml 中的代码:

<preference name="orientation" value="landscape" />
    <preference name="screen-orientation" value="landscape" />
    <preference name="permissions" value="none" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="7" />
    <preference name="android-installLocation" value="auto" />
    <preference name="Fullscreen" value="true" />
    <preference name="EnableViewportScale" value="true" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="SplashScreenDelay" value="10000" />

我还有一个处理锁屏的插件:

 <gap:plugin name="net.yoik.cordova.plugins.screenorientation" version="1.3.1" />

在 iphone 上一切都很好,但在 android 中,我该如何解决这些问题?

也许这会有所帮助?

http://docs.build.phonegap.com/en_US/configuring_config_file_element.md.html
http://stackoverflow.com/questions/4675750/lock-screen-orientation-android

为了更好地理解上传到 phonegap build 的程序结构:

  -css
    -img
    -js
    -lib (libraries like angular,jquery and such)
    -modules (all the html here)
    -res (icons and screen for splash and such)
    -spec (tests)
    application.js (my all javascript minified here)
    config.xml
    icon.png
    index.html
    spec.html
    splash.png

所有这些文件每次都被压缩,并上传到 phonegap-build

【问题讨论】:

    标签: android cordova screen-orientation


    【解决方案1】:

    尝试解决第一个问题,禁用底部栏是可能的,您必须为此活动设置SYSTEM_UI_FLAG_HIDE_NAVIGATION,它可以在本机代码中,或者,似乎可以使用这个@ 987654321@

    按照readme ,我通过将这段代码添加到应用程序的起点以最简单的快速和肮脏的方式使用它:

    AndroidFullScreen.leanMode(function(){alert("success");}, function(){alert("error");});
    

    对于第二个问题,这似乎是一个常见问题,干净的应用程序在 config.xml 中只有此首选项:

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

    效果很好,也许启动画面或其他偏好会影响您的项目。 您可以尝试检查文件 platforms/android/AndroidManifest.xml 中的活动是否具有在横向模式下工作的所有属性,如果是这样...您可以将此代码添加到 MainActivity.java 在 onCreate 方法中,在 super.onCreate(savedInstanceState); 之前:

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }
    

    通过这种方式,我们尝试对 config.xml 中的首选项实现的相同功能进行硬编码。

    【讨论】:

    • 上面的代码,可以放在哪里,以便在 phonegap-build 中进行解释,因为只有 www 文件夹在其中,而不是平台的东西等等......
    • 你的phonegap项目的根目录下没有platforms文件夹吗?
    • 在phonegap项目中是的,但是在phonegap构建中没有平台等,它只是要求phonegap项目中的www文件夹。
    • 在phonegap项目中改变它,它会在phonegap build中改变
    • 我的程序结构现在有问题了,只有压缩并发送到 phonegap-build 的东西
    猜你喜欢
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    • 2015-12-30
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    相关资源
    最近更新 更多