javascript SAPUI5 - 垂直布局重力

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29643752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:49:15  来源:igfitidea点击:

SAPUI5 - Vertical layout gravity

javascriptxmlsapui5

提问by miskohut

i have several elements on screen in xml file

我在 xml 文件中的屏幕上有几个元素

<core:View controllerName="myapp.view.login.login"
    xmlns="sap.m" xmlns:core="sap.ui.core"
    xmlns:l="sap.ui.layout">

    <l:VerticalLayout >
        <l:content>
            <Input 
                type="Text"
                maxLength="15"
                fieldWidth="15px"
                placeholder="name"
                textAlign="Center">
            </Input>

            <Input 
                type="Password"
                maxLength="15"
                fieldWidth="15px"
                placeholder="password"
                textAlign="Center">
            </Input>

            <Button 
                text="Log in"
                press="logIn">
            </Button>
        </l:content>

    </l:VerticalLayout>

</core:View>

how can i add something like layout gravity or align, I want these elements in the center of the screen. Could you help me with that? Thank you.

我如何添加布局重力或对齐之类的东西,我希望这些元素位于屏幕中央。你能帮我解决这个问题吗?谢谢你。

采纳答案by Qualiture

Since you're using the sap.mlibrary anyway, I would recommend to use the sap.m.VBoxcontrol (or sap.m.HBoxfor horizontal layouts) The VBoxdoes exactly the same as the VerticalLayoutand more (you can specify alignment, justification in a truly flexible way

由于您sap.m无论如何都在使用该库,因此我建议您使用sap.m.VBox控件(或sap.m.HBox用于水平布局)VBox与 完全相同VerticalLayout以及更多(您可以以真正灵活的方式指定对齐方式,对齐方式

The VBoxand HBoxinherit from FlexBox, see these examples on what you can do: https://sapui5.hana.ondemand.com/sdk/explored.html#/entity/sap.m.FlexBox/samples

VBoxHBox继承FlexBox,看到你可以做什么这些例子:https://sapui5.hana.ondemand.com/sdk/explored.html#/entity/sap.m.FlexBox/samples