How to disable letterboxing and adjust UI5 for the widescreen?

前端 未结 5 982
礼貌的吻别
礼貌的吻别 2020-12-06 08:35

I have an UI5-based app (1.66+), which works correctly, but there are huge empty spaces on the left and right sides of the screen (aka letterboxing is on):

相关标签:
5条回答
  • 2020-12-06 08:57

    Static implementation via XML-template:

    <mvc:View controllerName="letterboxing.widescreen.controller.index" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
        <Shell id="shell" appWidthLimited="false">
            <App id="app">
                <pages>
                    <Page id="page" title="{i18n>title}">
                        <content></content>
                    </Page>
                </pages>
            </App>
        </Shell>
    </mvc:View>
    

    For dynamic implementation via JS-controller with appWidthLimited: false in sap.m.Shell, see: https://stackoverflow.com/a/55867413

    0 讨论(0)
  • 2020-12-06 09:01

    You can achieve that removing the shell control from index.html:

    sap.ui.getCore().attachInit(function () {
        sap.ui.require(["sap/ui/core/ComponentContainer"], function (ComponentContainer) {
            new ComponentContainer({
                name: "yourProject",
                async: true,
                manifest: true,
                height: "100%"
    
            }).placeAt("content");
    
        });
    });
    

    instead of this:

    <script>
        sap.ui.getCore().attachInit(function () {
            new sap.m.Shell({
                app: new sap.ui.core.ComponentContainer({
                    height: "100%",
                    name: "APPNAME"
                }),
                appWidthLimited: false
            })
            .placeAt("content");
        });
    </script>
    
    0 讨论(0)
  • 2020-12-06 09:03

    Ok, so there seems to be many similar questions regarding how to disable/enable letterboxing. This answer should provide a solution for each case:

    Standalone Apps

    Look for the instantiation of sap.m.Shell in your project and configure appWidthLimited accordingly.

    For example:

    In index.html or index.js

    sap.ui.require([
      "sap/m/Shell",
      "sap/ui/core/ComponentContainer",
    ], (Shell, ComponentContainer) => new Shell({
      appWidthLimited: false|true, // <--
      // ...
    }).placeAt("content"));
    

    In root view

    <Shell xmlns="sap.m" appWidthLimited="false|true">
      <App>
        <!-- ... -->
    

    Of course, the Shell can be configured dynamically in JS too with myShell.setAppWidthLimited(false|true).

    API reference: sap.m.Shell
    UX guideline: Letterboxing


    Apps on SAP Fiori launchpad (FLP)

    The component / app …:

    • should not contain sap.m.Shell anywhere (please check the root view).
    • launches from FLP instead (no index.html).

    Statically in manifest.json

    "sap.ui": {
      "fullWidth": true|false,
      ...
    },
    

    Dynamically in runtime

    sap.ui.require([ // require the config singleton on-demand:
      "sap/ushell/services/AppConfiguration"
    ], config => config.setApplicationFullWidth(true|false));
    

    API reference: sap.ushell.services.AppConfiguration
    UX guideline: Letterboxing

    0 讨论(0)
  • 2020-12-06 09:09

    According to Available OpenUI5 Versions the newest OpenUI5 version is 1.65.0. How is you app based on 1.66.0?

    Setting appWidthLimited: false on the sap.m.Shell should do the work. Check out this example (plunker / github) (in the Plunker run preview in a new window)

    0 讨论(0)
  • 2020-12-06 09:16

    For some reason, AppConfiguration.setApplicationFullWidth(true); does not work for me. I don't have a valid application container.

    I solved the problem in this, admittedly hacky, way: In my app controller, I added this implementation of the onAfterRendering method:

    onAfterRendering: function () {
        var oElement = this.getView().byId("idAppControl").$();
        while (oElement && oElement.hasClass) {
            if (oElement.hasClass("sapUShellApplicationContainerLimitedWidth")) {
                oElement.removeClass("sapUShellApplicationContainerLimitedWidth");
                break;
            }
            oElement = oElement.parent();
        }
    }
    
    
    0 讨论(0)
提交回复
热议问题